Skip to content

Instantly share code, notes, and snippets.

@Ph3nol
Created January 20, 2012 15:56
Show Gist options
  • Save Ph3nol/1647991 to your computer and use it in GitHub Desktop.
Save Ph3nol/1647991 to your computer and use it in GitHub Desktop.
Symfony2 1 single Doctrine result
<?php
$query = $em->createQuery('SELECT ....')
->setMaxResults(1);
try {
$product = $query->getSingleResult();
} catch (\Doctrine\Orm\NoResultException $e) {
$product = null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment