Download the PHP package carrooi/doctrine-queries without Composer
On this page you can find all versions of the php package carrooi/doctrine-queries. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package doctrine-queries
Carrooi/DoctrineQueries
Builder for doctrine query builders based on kdyby/doctrine
Installation
QueryObject
Please, first read documentation of kdyby's QueryObjects.
Select filters
Selects
If you have more methods which selects different columns, you will run into errors about already selected columns. You can avoid that by using some helper methods.
DQL: SELECT PARTIAL u.{id,nick,email} FROM ...
With result alias:
DQL: SELECT PARTIAL u.{id,nick,email} AS user FROM ...
Or with distinct:
You can also use classic column selects without partials. That can be useful for example for array hydration.
DQL: SELECT u.nick AS nickAlias, PARTIAL u.{id,email} FROM ...
Joins
Same problem like with selects is with joins. If you will try to join same relation many times, you will get error. Again, there are methods for that.
You can also use tryLeftJoin
method.
Helpers
$query->addParameters(QueryBuilder $qb, array $parameters)
: set parameters without overwriting the old ones
Nested trees searching
If you are using eg. gedmo nested trees, you could also use TNestedTreeQuery
trait for simple searching in tree.
That example will find all entities in database with at least one entity from given array of entities, even they are same, in some children entity or some parent entity.
Search by at least one entity (uses OR) default
Search by all entities (uses AND)
Search only for same, in parents and in children default
Search only for same
Search only in parents
Search only in children
Combined searching
Custom column names
TNestedTreeQuery
trait will use by default these column names:
id
level
root
left
right
But if you need, you can use custom names:
Getting results
getQueryBuilder()
getResultSet()
getResult()
getPairs()
getOneOrNullResult()
getSingleScalarResult()
Changelog
-
1.2.1
- Change dependencies
-
1.2.0
- Better aliases in tree searching DQLs
- Support for classic custom column selects (not just partials)
- Add option to set result alias for partial selects
-
1.1.0
- Add field function for DQL
- Add TNestedTreeQuery trait for searching in nested trees
-
1.0.1
- Do not rewrite existing joins
- 1.0.0
- Initial version