$queryBuilder->select('o')->from('Object', 'o')->where($queryBuilder->expr()->in('o.id', $ids));
Where $ids = array(1, 2, 5, 6, ...). This works very well. On the other hand, the following equivalent DQL yields only 1 result: whichever id is the first in the $ids list.
$this->getEntityManager()->createQuery('SELECT o FROM Object o '.
->setParameter('ids', implode(', ', $ids));
评论
发表评论