Skip to content

Commit

Permalink
Reverted removal of getSingleResult()
Browse files Browse the repository at this point in the history
It's now smaller (25 to 3 lines) and uses getOneOrNullResult().
  • Loading branch information
wouterj committed Feb 3, 2014
1 parent c98a3da commit 7acc0d2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion book/doctrine.rst
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,11 @@ a controller, do the following::

$products = $query->getResult();

The ``getResult()`` method returns an array of results.
The ``getResult()`` method returns an array of results. To get only one
result, you can use ``getSingleResult()`` (which throws exception there is no
result) or ``getOneOrNullResult()``::

$product = $query->getOneOrNullResult();

If you're comfortable with SQL, then DQL should feel very natural. The biggest
difference is that you need to think in terms of "objects" instead of rows
Expand Down

0 comments on commit 7acc0d2

Please sign in to comment.