doctrine2 where in的问题


$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 '.
      'WHERE o.id IN (:ids) ')
      ->setParameter('ids', implode(', ', $ids));

评论

热门博文