diff --git a/en/reference/dql-doctrine-query-language.rst b/en/reference/dql-doctrine-query-language.rst index e592b9e02..e26d8ecab 100644 --- a/en/reference/dql-doctrine-query-language.rst +++ b/en/reference/dql-doctrine-query-language.rst @@ -253,6 +253,9 @@ Using Aggregate Functions: $query = $em->createQuery('SELECT COUNT(u.id) FROM Entities\User u'); $count = $query->getSingleScalarResult(); + $query = $em->createQuery('SELECT u, count(g.id) FROM Entities\User u JOIN u.groups g GROUP BY u.id'); + $result $query->getResult(); + With WHERE Clause and Positional Parameter: .. code-block:: php @@ -916,7 +919,7 @@ structure: .. code-block:: php - $dql = "SELECT u, 'some scalar string', count(u.groups) AS num FROM User u"; + $dql = "SELECT u, 'some scalar string', count(u.groups) AS num FROM User u JOIN u.groups g GROUP BY u.id"; array [0] diff --git a/en/reference/working-with-objects.rst b/en/reference/working-with-objects.rst index 736401ac8..a47b13ef4 100644 --- a/en/reference/working-with-objects.rst +++ b/en/reference/working-with-objects.rst @@ -690,6 +690,13 @@ methods on a repository as follows: // A single user by its nickname $user = $em->getRepository('MyProject\Domain\User')->findOneBy(array('nickname' => 'romanb')); +You can also load by owning side associations through the repository: + + $number = $em->find('MyProject\Domain\Phonenumber', 1234); + $user = $em->getRepository('MyProject\Domain\User')->findOneBy(array('phone' => $number->getId())); + +Take not that this only works by passing the ID of the associated entity, not yet by passing the associated entity itself. + An EntityRepository also provides a mechanism for more concise calls through its use of ``__call``. Thus, the following two examples are equivalent: