Reputation: 2871
I have array of products IDs. I have to make query like this:
SELECT * FROM products WHERE pid IN (1, 2, 8, 4, ...) // etc
I have my ids in variable $pids.
$qb = $em->createQueryBuilder();
$query = $qb->select('p.pid')
->from('SRC\MainBundle\Entity\Product', 'p')
->where('p.name IN :pids') // error is HERE
->setParameter('pids', $pids)
->getQuery();
Doesn't work. I get an error:
[Syntax Error] line 0, col 66: Error: Expected Doctrine\ORM\Query\Lexer::T_OPEN_PARENTHESIS, got ':pids'
Upvotes: 3
Views: 6510
Reputation: 254944
What if you try
->where('p.name IN (:pids)') // error is HERE
It explicitly says to you that it expects parentheses
but gets placeholder
Upvotes: 17