php - Symfony - how to use an array as an parameter by using a querybuilder?Get the solution ↓↓↓
I think you want to use "IN" syntax, not "=" syntax:
'SELECT w FROM WaiverBundle:Waiver w WHERE w.carrier IN (:carrier) AND w.market = :market ORDER BY w.id DESC'
Your query is not complicated. I think you should consider QueryBuilder instead of DQL in this case. Something like this would do the trick:
$qb = $em->createQueryBuilder(); $qb->select('w') ->from('WaiverBundle:Waiver', 'w') ->where($qb->expr()->in('w.carrier', ':carrier')) ->andWhere($qb->expr()->eq('w.market', ':market')) ->orderBy('w.id', 'DESC') ->setParameters( array( 'carrier'=>$user_airlines, 'market'=>$user_markets[0) );
Share solution ↓
Link To Answer People are also looking for solutions of the problem: foreach() argument must be of type array|object, null given
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.