我有一个状态对象的 ArrayCollection,现在我想将其用作 WHERE 子句中的 IN 参数以进行学说查询。这是我的查询代码:
$query = $repository->createQueryBuilder('r')
->join('r.applicationStatus', 's')
->where('r.submitted IS NOT NULL')
->andWhere('r.created >= :date')
->andWhere('r.created < :date2')
->andWhere('s IN (:status)') // Here's the In statement
->orderBy('r.created', 'DESC')
->setParameter('date', $appSearch->getDateFrom())
->setParameter('date2', $end)
->setParameter('status', $appSearch->getApplicationStatus()) //Here's the array collection
->getQuery();
但是查询返回零记录。为了让它工作,我必须手动遍历 $appSearch->getApplicationStatus() arraycollection 并在一个新的数组中获取状态 ID,以便查询目前产生正确的结果 - 这感觉非常低效。
我究竟做错了什么?