Doctrine Query Builder using Array

后端 未结 3 569
迷失自我
迷失自我 2021-02-10 16:51

I have an array of id:

Id_array; //array(2) { [0]=> int(9) [1]=> int(10) } 

I simply want to select the users using Id_array; I managed

3条回答
  •  醉梦人生
    2021-02-10 17:36

    In case someone runs into something similar, I used the query builder, The key point is to use the IN statement.

    //...
    $qb = $this->createQueryBuilder('u');
    $qb->add('where', $qb->expr()->in('u.id', ':my_array'))
    ->setParameter('my_array', $Id_array);
    

提交回复
热议问题