0
我有一个一对多的实体:添加巢OR语句学说2,QueryBuilder的
User -> OrderPerson
用户可以拥有多个orderPersons。
OrderPerson已链接到订单,并且可以有多个订单。
我想要做的是建立一个动态查询,以解决这个问题,这是我迄今:
public function getPaged($page, $count , $orderPersons = null)
{
$qb = $this->orderRepository->createQueryBuilder('c')
->orderBy('c.id', 'DESC');
if ($orderPersons != null)
{
foreach ($orderPersons AS $orderPerson)
{
$qb->where('c.orderPerson='.$orderPerson); ***
}
}
$query = $qb->getQuery();
}
当我奋力是怎么写的行:
$qb->where('c.orderPerson='.$orderPerson);
我的文档的阅读,我想我需要使用这样的事情,但我不知道:
$qb->andWhere(
$qb->expr()->orX(
$qb->expr()->eq('c.orderPerson='.$orderPerson)
)
);
然而,我不确定如何将它放入循环中。
谢谢 - 一切工作。 – HappyCoder