Skip to content

Commit 7acc0d2

Browse files
committed
Reverted removal of getSingleResult()
It's now smaller (25 to 3 lines) and uses getOneOrNullResult().
1 parent c98a3da commit 7acc0d2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

book/doctrine.rst

+5-1
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,11 @@ a controller, do the following::
737737

738738
$products = $query->getResult();
739739

740-
The ``getResult()`` method returns an array of results.
740+
The ``getResult()`` method returns an array of results. To get only one
741+
result, you can use ``getSingleResult()`` (which throws exception there is no
742+
result) or ``getOneOrNullResult()``::
743+
744+
$product = $query->getOneOrNullResult();
741745

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

0 commit comments

Comments
 (0)