2017 © Pedro Peláez
 

library doctrine-query-builder

An elegant lightweight library to dynamically build doctrine queries from structured data. Perfect for an API to interpret how data should be represented without any additional mapping.

image

warrantgroup/doctrine-query-builder

An elegant lightweight library to dynamically build doctrine queries from structured data. Perfect for an API to interpret how data should be represented without any additional mapping.

  • Wednesday, January 24, 2018
  • by lewisdwilliams
  • Repository
  • 5 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

doctrine-query-builder

An elegant lightweight library to dynamically build doctrine queries from structured data. Perfect for an API to interpret how data should be represented without any additional mapping., (*1)

Supports unlimited nested AND/OR groups, most of the common SQL operators, joins, order by, distinct etc, (*2)

Requirements:

  • PHP >= 5.6
  • Symfony HTTP Foundation > 3.2
  • Doctrine ORM > 2.5

Installation:

With Composer:, (*3)

{
    "require": {
        "warrantgroup/doctrine-query-builder": "dev-master"
    }
}

Usage:

use \Warrant\Doctrine\QueryBuilder\QueryBuilder;

$repo = $this->getDoctrine()->getManager()->getRepository('AcmeMainBundle:Person');
$qb = new QueryBuilder();

$results = $qb->build($repo, $data)->getQuery()->getResult();

return new JsonResponse($results);

Example data:

{
    "alias": "p",
    "select": ["p.id"],
    "where": {
        "$or": {
            "p.city": {
                "$same": "c.city"
            },
            "p.zipCode": {
                "$same": "c.zipCode"
            },
            "p.street": {
                "$same": "c.street"
            },
        },
        "c.city": {
            "$in": [
                "New York",
                "London"
            ]
        },
        "c.employees": { "$equals": 1 },
        "l.code": 49,
        "p.country": "$not_null",
        "p.phone": "$is_null",
        "c.assets": { "$gte": 1000 },
        "c.turnover": { "$lt": 10000 },
        "t.code": {
            "$in": [1, 2, 3]
        },
        "r.title": {
            "$not_in": ":titles"
        }
    },
    "distinct": true,
    "params": {
        "titles": ["CFO", "CMO"]
    },
    "orderBy": {
        "p.name": "asc"
    },
    "join": {
        "p.roles": "r",
        "r.company": "c",
        "c.trades": {
            "alias": "t",
            "type": "left"
        }
    }
}

The Versions

24/01 2018

dev-master

9999999-dev

An elegant lightweight library to dynamically build doctrine queries from structured data. Perfect for an API to interpret how data should be represented without any additional mapping.

  Sources   Download

MIT

The Requires

 

by Warrant Group Limited

14/05 2017

0.1.1

0.1.1.0

Very powerful query builder, perfect for apis

  Sources   Download

MIT

The Requires

 

21/03 2017

0.1.0

0.1.0.0

Very powerful query builder, perfect for apis

  Sources   Download

MIT

The Requires