如何在Doctrine 2.0中使用DQL中的in语句

use*_*868 26 doctrine-orm

我有以下使用IN语句的查询.

$ids = array(1,2,3);
$query = 'select o from Organisation o where o.id in (:ids)';
$this->_entityManager->createQuery($query)
            ->setParameter('ids', implode(', ', $ids))
Run Code Online (Sandbox Code Playgroud)

Doctrine没有返回任何结果,我认为这是因为Doctrine对传递的参数$ids(即数组)所做的转换有问题.

如何使它工作?

Jer*_*cks 47

尝试将数组本身传递给->setParameter(...)而不是将其插入字符串中.