Skip to content

Instantly share code, notes, and snippets.

@serapheem
Created July 24, 2013 07:14
Show Gist options
  • Save serapheem/6068609 to your computer and use it in GitHub Desktop.
Save serapheem/6068609 to your computer and use it in GitHub Desktop.
Doctrine 2 - Using identifier of relation in DQL query
<?php
$qb = $this->get('doctrine.orm.entity_manager')->createQueryBuilder();
$qb->select('v.id')
->from('CormesClipkitApiBundle:Video', 'v')
->where('IDENTITY(v.user) in (?1)')
->setParameter(1, $coIds)
->setFirstResult(rand(0, $count - $resnum))
->setMaxResults($resnum);
$result = $qb->getQuery()->getResult();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment