Giter VIP home page Giter VIP logo

slidoctrinearrayquerybuilderbundle's Introduction

SliDoctrineArrayQueryBuilderBundle Build Status

With this bundle on board you will be able to build complex DQL queries using a simple PHP associative arrays notation, this way simplicity of writing queries goes on a whole new level, analytical applications which must allow to build queries from UI will especially benefit from this bundle (bundle out of the box supports client/server communication protocol used by ExtJs framework, in other words).

Teaser

Say that we have a classical User and Group entities associated as ManyToMany and that User entity have OneToOne association with Profile entity, this is how a sample query could look like:

$query = array(
    'filter' => [
        // if the property is OneToMany relation and IN query is used the MEMBER OF query will be built automatically
        array('property' => 'groups', 'value' => 'in:1,2,3'),
        array('property' => 'username', 'value' => 'like:John%'),
        // this will automatically build proper JOINS under the hood
        array('property' => 'profile.insurance.securityNumber', 'value' => 'isNull')
    ],
    'fetch' => [
        // this will inform array query builder that you want to have associated Profile and then Insurance entities
        // to be fetched as well
        'profile.insurance'
    ],
    'sort' => [
        array('property' => 'id', 'direction' => 'DESC')
    ],
    'page' => 1,
    'limit' => 25
);

/* @var \Sli\DoctrineArrayQueryBuilderBundle\Querying\ArrayQueryBuilder $aqb */
$aqb = $container->get('sli_doctrine_array_query_builder.querying.array_query_builder');

// Only those users will be returned:
// 1. belong to groups with IDS 1, 2 and 3
// 2. whose `username`s contain John
// 3. whose associated Insurance entity's securityNumber is NULL
// Result will be ordered by ID field and paginated
$users = $aqb->buildQuery('MyCompany\MyBundle\Entity\User', $query);

For all supported functionality please see a functional test located in Tests/Functional/Querying/ArrayQueryBuilderTest.php.

Supported filtering operators:

  • eq
  • neq
  • like
  • notLike
  • gt
  • gte
  • lt
  • lte
  • in
  • notIn
  • isNull
  • isNotNull

Installation

Add this dependency to your composer.json:

"sergeil/doctrine-array-query-builder-bundle": "dev-develop"

Update your AppKernel class and add this:

new \Sli\DoctrineArrayQueryBuilderBundle\SliDoctrineArrayQueryBuilderBundle(),

Licensing

This bundle is under the MIT license. See the complete license in the bundle: Resources/meta/LICENSE

slidoctrinearrayquerybuilderbundle's People

Contributors

sergeil avatar

Watchers

 avatar

slidoctrinearrayquerybuilderbundle's Issues

Bad service definitions

[Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException]
The service "sli_doctrine_array_query_builder.querying.array_query_builder" has a dependency on a non-existent service "sli_doctrine_entity_data_mapper.mapping.entity_data_ma
pper".

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.