Skip to content

Commit 8e6b9f6

Browse files
mel1289javiereguiluz
authored andcommitted
Less code
1 parent afb1a60 commit 8e6b9f6

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

doctrine/associations.rst

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -375,11 +375,7 @@ following method to the ``ProductRepository`` class::
375375
WHERE p.id = :id'
376376
)->setParameter('id', $productId);
377377

378-
try {
379-
return $query->getSingleResult();
380-
} catch (\Doctrine\ORM\NoResultException $exception) {
381-
return null;
382-
}
378+
return $query->getOneOrNullResult();
383379
}
384380

385381
Now, you can use this method in your controller to query for a ``Product``

0 commit comments

Comments
 (0)