Skip to content
This repository has been archived by the owner on Mar 30, 2018. It is now read-only.

Commit

Permalink
Clarifications and additions in DQL and Working with objects chapter
Browse files Browse the repository at this point in the history
  • Loading branch information
beberlei committed Jun 11, 2011
1 parent a5cfd23 commit 6f909b6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion en/reference/dql-doctrine-query-language.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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();

This comment has been minimized.

Copy link
@Guite

Guite Jun 11, 2011

There is a equal sign (=) missing here.

This comment has been minimized.

Copy link
@beberlei

beberlei Jun 11, 2011

Author Member

ah thanks!

With WHERE Clause and Positional Parameter:

.. code-block:: php
Expand Down Expand Up @@ -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]
Expand Down
7 changes: 7 additions & 0 deletions en/reference/working-with-objects.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 6f909b6

Please sign in to comment.