Last active
August 11, 2017 02:39
-
-
Save bjunc/596081c25eb9497f8b25739f8b37a5f5 to your computer and use it in GitHub Desktop.
lightweight Symfony entity query with alias
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// lightweight retrieval of orgId from alias | |
$em = $this->getDoctrine()->getManager(); | |
$query = $em->createQuery('SELECT org.oid FROM AppBundle:Organization org WHERE org.slug = :alias OR org.oid = :alias')->setParameter('alias', $orgAlias); | |
$org = $query->getOneOrNullResult(); | |
if (!$org) throw new \Exception('Not Found', 404); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment