How to write a DQL select statement to search some, but not all the entities in a single table inheritance table

前端 未结 3 641
野的像风
野的像风 2021-02-01 08:16

So I have 3 entities within one table. I need to be able to search 2 out of the 3 entities in one select statement, but I\'m not sure how to do this.

3条回答
  •  暖寄归人
    2021-02-01 09:08

    As commented by flu, if you want to retrieve some entities from different instances with a QueryBuilder instead of a DQL query, you can use an array as parameter:

    $qb = $this->createQueryBuilder('u');
        ->where('u.id > 10') //an arbitrary condition, to show it can be combined with multiple instances tests
        ->andWhere('u INSTANCE OF :classes')
        ->setParameter('classes', ['Entity\Manager', 'Entity\Customer'])
    ;
    

提交回复
热议问题