Doctrine Query Builder using Array

后端 未结 3 570
迷失自我
迷失自我 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:52

    Or without the query builder:

    $query = $em->createQuery('SELECT u FROM Users u WHERE u.id IN (:id)');
    $query->setParameter('id', array(1, 9));
    $users = $query->getResult();
    

提交回复
热议问题