Doctrine删除使用Querybuilder和IN

时间:2015-03-27 14:47:32

标签: doctrine-orm

    $qb = $this->getDoctrine ()->getEntityManager()->createQueryBuilder();
    $qb->delete('MainBundle:StatisticUser', 'u');
    $qb->where($qb->expr()->in('sessionid', array_keys($sessionidsToTruncate)));
    var_dump($qb->getQuery());
    $qb->getQuery()->execute();

private '_dql' => string 'DELETE MainBundle:StatisticUser u WHERE sessionid IN('asdfghjkl')' (length=75)

但我收到错误

[Semantical Error] line 0, col 50 near 'sessionid IN': Error: 'sessionid' is not defined. 

有人能指出我的问题吗?

1 个答案:

答案 0 :(得分:0)

好的,我找到了试验和错误的解决方案:

$qb->andWhere($qb->expr()->in('u.sessionid', array_keys($sessionidsToTruncate)));