[DDC-2177] WHERE IN not working Created: 28/Nov/12  Updated: 29/Nov/12  Resolved: 28/Nov/12

Status: Closed
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.3
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Moritz Kraft Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: None
Environment:

Linux, Symfony 2, PHP 5.3.10



 Description   

I'm going by the docs, trying to get a WHERE IN type of query working with the query builder.

I've got a flat array of IDs, e.g. something like this:

$IDs = array( 228052, 265635, 344498, 391761, 329203, 317911, 305961, 299939, 249429, 344706 );

I've tried the following ways to get this working:

  • using the Expr class:

$qb->add( 'where', $qb->expr()->in( 'c.id', ':IDs' ));
$qb->setParameter( 'IDs', $IDs );

  • alternatively:

$qb->add( 'where', $qb->expr()->in( 'c.id', $IDs ));

  • even direct DQL:

$qb->where( 'c.id IN (:IDs)' );
$qb->setParameter( 'IDs', $IDs );

The generated DQL looks fine:

SELECT c FROM MyEntity c WHERE c.id IN('228052', '265635', '344498', '391761', '329203', '317911', '305961', '299939', '249429', '344706')

But when I call execute() on that query, all these variations give me the following error:

Expected argument of type "Doctrine\ORM\QueryBuilder", "array" given



 Comments   
Comment by Moritz Kraft [ 28/Nov/12 ]

never mind.... it was something i was doing wrong. thank god...

Comment by Marco Pivetta [ 28/Nov/12 ]

Moritz Kraft what was it exactly?

Comment by Moritz Kraft [ 29/Nov/12 ]

The error was thrown by the Symfony Form Framework, not Doctrine. Sorry about that. :-/

Generated at Thu Jul 31 22:02:18 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.