Doctrine findBy with OR condition

后端 未结 4 1646
夕颜
夕颜 2021-02-04 23:54

Is it possible to use OR statement in Doctrine findBy() method? I know that given array is interpreted as case1 AND case2... Like this

4条回答
  •  臣服心动
    2021-02-05 00:21

    As far as I know this is not a supported feature by Doctrine to use IN() queries with findby. You could do two things:

    1. Implement a findByStatus(array $statusTypes) method in your (custom) 'notif' repository class. If you like this approach I can give you a example.

    2. Convert your findBy to the following:

      $qb = $this->repos['notif']->createQueryBuilder('n');
      $data = $qb->where($qb->expr()->in('status', array(1,2,3)))->getQuery()->getResult();
      

    That should work either :)

提交回复
热议问题