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