GithubHelp home page GithubHelp logo

queryutils's Introduction

Query Utils

Set of Doctrine ORM query helpers.

Prepared Queries

All predefined queries share common ancestor: Query\BaseQuery. This class exposes these public methods:

  1. bindExprTo($qb) - binds generated expression to your QueryBuilder,
  2. bindParametersTo($qb) - binds generated parameters to your QueryBuilder,
  3. bindTo($qb) - binds expression and parameters to your QueryBuilder.

Also, bindExprTo and bindTo have second, optional parameter $method which defaults to and. This represents method used for binding.

  1. if and is passed, $qb->andWhere(...) is used,
  2. if or is passed, $qb->orWhere(...) is used.

Full-text Query

For string $q to lookup on columns client.firstName and client.lastName use following:

long form:

$helper = new \ADT\QueryUtils\Query\FullTextQuery($q, [
    'client.firstName', 'client.lastName'
]);
 
$helper->bindTo($queryBuilder);

or short form:

\ADT\QueryUtils\Query\FullTextQuery::create($q, [
    'client.firstName', 'client.lastName'
])->bindTo($queryBuilder);

queryutils's People

Contributors

michallohnisky avatar

Stargazers

Tomáš Kudělka avatar

Watchers

Tomáš Kudělka avatar James Cloos avatar Jiří Tužil avatar  avatar _oli avatar  avatar

Forkers

michallohnisky

queryutils's Issues

Předávání prefixů až později

@Danoha
Takovýchto helperů bych chtěl mít víc.

Toto ještě není finální podoba, představoval bych si to ještě bez toho parametru $entityName, který by se zadával buď při bindování, tedy ->bindTo($qb, 'e'), nebo zvlášt, tedy ->setEntityName('e')->bindTo($qb).

Potom bych chtěl ještě dynamický název parametru. Alespoň prefix. Když se pak staví nějaký velký query a potřeboval bych filtrovat 2x podle stejného filtru, tak to bude kolidovat.

Takže nejlépe jako ->setParameterPrefix('user1')->bindTo($qb) nebo rovnou ->bindTo($qb, 'e', 'user1').

Problém pak je v tom, jak takové helpery psát co nejjednodušejc. Chtěl bych toto concatenování stringů úplně odříznout. Všude by se psalo e.field a e. by se nahrazovalo za $entityName.? Psalo by se :param a nahradilo by se za :$parameterPrefix_param?

A potom nevím, jestli helpery pro Usery psát do jednoho souboru, nebo jestli pro každý helper nový?

Půjdeme cestou dvou callbacků, jeden pro expr a jeden pro parametry. Zkrátíme názvy prefixů na $e a $p.

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.