Symfony QueryBuilder OneToMany过滤器实体,无关系

Symfony QueryBuilder OneToMany过滤器实体,无关系,symfony,doctrine-orm,Symfony,Doctrine Orm,我有一个模型 一家之家(人) 人@马尼通(住宅) 我需要一个QueryBuilder来过滤所有没有人的房子 当前不工作代码 $houseRepository ->createQueryBuilder('h') ->join('h.people', 'p') ->where('p is NULL'); 始终不返回任何信息,我在数据库中有3个房子,只有一个有人您需要使用left join进行此类查询。比如: $houseRepository -

我有一个模型

  • 一家之家(人)
  • 人@马尼通(住宅)
我需要一个QueryBuilder来过滤所有没有人的房子

当前不工作代码

$houseRepository
    ->createQueryBuilder('h')
    ->join('h.people', 'p')
    ->where('p is NULL');

始终不返回任何信息,我在数据库中有3个房子,只有一个有人

您需要使用left join进行此类查询。比如:

$houseRepository
    ->createQueryBuilder('h')
    ->leftJoin('h.people', 'p')
    ->where('p is NULL');

对于此类查询,您需要使用left join。比如:

$houseRepository
    ->createQueryBuilder('h')
    ->leftJoin('h.people', 'p')
    ->where('p is NULL');

对于此类查询,您需要使用left join。比如:

$houseRepository
    ->createQueryBuilder('h')
    ->leftJoin('h.people', 'p')
    ->where('p is NULL');

对于此类查询,您需要使用left join。比如:

$houseRepository
    ->createQueryBuilder('h')
    ->leftJoin('h.people', 'p')
    ->where('p is NULL');