Doctrine 2 WHERE IN clause using a collection of entities

前端 未结 4 711
太阳男子
太阳男子 2020-12-09 09:27

I\'m attempting to build a query in Doctrine 2 that finds all Vacancy entities which are related to any of the given VacancyWorkingHours entities.<

4条回答
  •  离开以前
    2020-12-09 09:38

    Try to set IDs as parameter

    $ids = array();
    foreach($workingHours as $w) {
        $ids[] = $w->getId();
    }
    

    Then

    $q = $this->createQueryBuilder('v')
        ->select('v')
        ->andWhere('v.workingHours IN (:workingHours)')
        ->setParameter('workingHours', $ids);
    ;
    

提交回复
热议问题