DDC-2177: WHERE IN not working #2741

Closed
opened 2026-01-22 14:02:04 +01:00 by admin · 4 comments
Owner

Originally created by @doctrinebot on GitHub (Nov 28, 2012).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user userfriendly:

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

Originally created by @doctrinebot on GitHub (Nov 28, 2012). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user userfriendly: 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
admin added the Bug label 2026-01-22 14:02:04 +01:00
admin closed this issue 2026-01-22 14:02:05 +01:00
Author
Owner

@doctrinebot commented on GitHub (Nov 28, 2012):

Comment created by userfriendly:

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

@doctrinebot commented on GitHub (Nov 28, 2012): Comment created by userfriendly: never mind.... it was something i was doing wrong. :) thank god...
Author
Owner

@doctrinebot commented on GitHub (Nov 28, 2012):

Issue was closed with resolution "Invalid"

@doctrinebot commented on GitHub (Nov 28, 2012): Issue was closed with resolution "Invalid"
Author
Owner

@doctrinebot commented on GitHub (Nov 28, 2012):

Comment created by @ocramius:

[~userfriendly] what was it exactly?

@doctrinebot commented on GitHub (Nov 28, 2012): Comment created by @ocramius: [~userfriendly] what was it exactly?
Author
Owner

@doctrinebot commented on GitHub (Nov 29, 2012):

Comment created by userfriendly:

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

@doctrinebot commented on GitHub (Nov 29, 2012): Comment created by userfriendly: The error was thrown by the Symfony Form Framework, not Doctrine. Sorry about that. :-/
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#2741