Add note clarifying WHERE, WITH and HAVING
- A per Ocramius' explanation in #6563
This commit is contained in:
parent
80573038ed
commit
624af3df22
@ -356,7 +356,8 @@ article-ids:
|
|||||||
$query = $em->createQuery('SELECT u.id, a.id as article_id FROM CmsUser u LEFT JOIN u.articles a');
|
$query = $em->createQuery('SELECT u.id, a.id as article_id FROM CmsUser u LEFT JOIN u.articles a');
|
||||||
$results = $query->getResult(); // array of user ids and every article_id for each user
|
$results = $query->getResult(); // array of user ids and every article_id for each user
|
||||||
|
|
||||||
Restricting a JOIN clause by additional conditions:
|
Restricting a JOIN clause by additional conditions specified by
|
||||||
|
WITH:
|
||||||
|
|
||||||
.. code-block:: php
|
.. code-block:: php
|
||||||
|
|
||||||
@ -489,6 +490,17 @@ Joins between entities without associations were not possible until version
|
|||||||
<?php
|
<?php
|
||||||
$query = $em->createQuery('SELECT u FROM User u JOIN Blacklist b WITH u.email = b.email');
|
$query = $em->createQuery('SELECT u FROM User u JOIN Blacklist b WITH u.email = b.email');
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
The differences between WHERE, WITH and HAVING clauses may be
|
||||||
|
confusing.
|
||||||
|
|
||||||
|
- WHERE is applied to the results of an entire query
|
||||||
|
- WITH is applied to a join as an additional condition. For
|
||||||
|
arbitrary joins (SELECT f, b FROM Foo f, Bar b WITH f.id = b.id)
|
||||||
|
the WITH is required, even if it is 1 = 1
|
||||||
|
- HAVING is applied to the results of a query after
|
||||||
|
aggregation (GROUP BY)
|
||||||
|
|
||||||
Partial Object Syntax
|
Partial Object Syntax
|
||||||
^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user