Last Updated: February 25, 2016
·
6.006K
· andreia

Symfony2 and Doctrine2: INDEX BY in QueryBuilder

E.g.: INDEX BY id of the User entity:

$qb = $em->createQueryBuilder();

$qb->select('u')
   ->from('SomeUserBundle:User', 'u', 'u.id')
   ->add('where', $qb->expr()->like('u.roles', ':role'))
   ->setParameter('role', $role);

Reference:
http://www.doctrine-project.org/jira/browse/DDC-2322