8

I want to make a findBy in doctrine with the IN-Operator, like in SQL:

...WHERE column_name IN (value1,value2,...);

Is it possible to do this in the criteria array of the entity-repository's findBy?

this->entityRepository->findBy($criteria, $orderBy, $limit, $offset);

Or must I do this with DQL?

Zwen2012
  • 3,360
  • 9
  • 40
  • 67

1 Answers1

17

Yes, you can!

$repository->findBy(['column_name' => ['value1', 'value2', '...']]);

Danizord
  • 433
  • 1
  • 4
  • 7
  • 2
    Came across this and it works fine. In case someone is wondering this performs an IN () query and not an OR query. – Ne Ma Apr 17 '17 at 15:33