Search code examples
phpcrudfuelphp

where in clause and query multiple IDs using FuelPHP


Model_Article::query()->where('id', 4);

I'm using FuelPHP. I have query like the above.

And I have an arrays of ID's

$ids = array(1, 2, 4, 8 ...);

How do I apply my array of id's to write this query using that format?

Thanks a lot!


Solution

  • Feed the 'IN' inside the ->where() to create an IN() clause:

    Model_Article::query()->where('field_name', 'IN', array(1,2,3,4,5))->get();