Giter Site home page Giter Site logo

doctrine-dbal's Introduction

Doctrine DBAL compilation target for RulerZ Build Status

Doctrine DBAL compilation target for RulerZ.

Usage

Doctrine DBAL is one of the targets supported by RulerZ.

This cookbook will show you how to retrieve records using Doctrine DBAL and RulerZ.

Here is a summary of what you will have to do:

Configure Doctrine DBAL

This subject won't be directly treated here. You can either follow the official documentation or use a bundle/module/whatever the framework you're using promotes.

Configure RulerZ

Once Doctrine DBAL is installed and configured we can the RulerZ engine:

$rulerz = new RulerZ(
    $compiler, [
        new \RulerZ\DoctrineDBAL\Target\DoctrineDBAL(), // this line is Doctrine DBAL-specific
        // other compilation targets...
    ]
);

The only Doctrine DBAL-related configuration is the DoctrineDBAL target being added to the list of the known compilation targets.

Filter your target

Now that both the DBAL and RulerZ are ready, you can use them to retrieve data.

The DoctrineDBAL instance that we previously injected into the RulerZ engine only knows how to use Doctrine\DBAL\Query\QueryBuilder so the first step is to create one and configure it:

$connection = DriverManager::getConnection([/** connection parameters */]);
$queryBuilder = $connection->createQueryBuilder();

$queryBuilder
    ->select('pseudo', 'gender', 'points')
    ->from('players');

And as usual, we call RulerZ with our target (the QueryBuilder object) and our rule. RulerZ will build the right executor for the given target and use it to filter the data, or in our case to retrieve data from a database.

$rule  = 'gender = :gender and points > :points';
$parameters = [
    'points' => 30,
    'gender' => 'M',
];

var_dump(
    iterator_to_array($rulerz->filter($queryBuilder, $rule, $parameters))
);

That's it!

License

This library is under the MIT license.

doctrine-dbal's People

Contributors

k-phoen avatar andrew-demb avatar xdimedrolx avatar

Watchers

 avatar

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.