I am trying run filters with doctrine query builder, i am using expr eq, but if i don´t have filter value, i would like to use some special symbol for expr eq which returs all rows.
my code:
$q = $qb->select(array('p'))
->from(payment::class, 'p')
->innerJoin(customer::class, 'z', 'WITH', 'p.customer= z.id')
->where(
$qb->expr()->eq('z.id', '?2')
)
->setMaxResults($limit)
->setFirstResult($offset)
->orderBy('p.'.$sortField, $sortType)
there i want somting like(->setParameter(2, "*"))
->setParameter(2, $filtry['customer'])
->getQuery();
return $q->getResult();
Is it possible? I don´t want write different query builder for each filter.
Sorry for my English
Thanks
It's a query builder so you can add params conditionally, as example:
$qb->select(array('p'))
->from(payment::class, 'p')
->innerJoin(customer::class, 'z', 'WITH', 'p.customer= z.id')
->setMaxResults($limit)
->setFirstResult($offset)
->orderBy('p.'.$sortField, $sortType)
if ($filtry['customer'])
{
$qb->andWhere(
$qb->expr()->eq('z.id', $filtry['customer'])
)
};
$q = $qb->getQuery()
Hope this help
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With