pass array of conditions to doctrine expr()->orx() method

后端 未结 5 1712
忘掉有多难
忘掉有多难 2020-12-25 10:56

I need to construct DQL with a QueryBuilder like this

[QUERY]... AND WHERE e.type = x OR e.type = Y OR e.type = N [...]

I hav

5条回答
  •  隐瞒了意图╮
    2020-12-25 11:07

    @DEY his answer can be simplified. No need for the foreach, this also works:

    $conditions = array('e.type = x', 'e.type = Y', 'e.type = N');
    
    $orX = $qb->expr()->orX();
    $orX->addMultiple($conditions);
    
    $qb->where($orX);
    

提交回复
热议问题