We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Multi conditions query

Hello, I have an array that contains 'id'' 's of items that i need to pull from my database. Is it possible to set that array for my find() conditions or something like that? I need to get data of that items from array.

Thx



93.7k
Accepted
answer

Are you talking about IN clause?

$robots = Robots::find([
    'id IN ({ids:array})',
    'bind' => [
        'ids' => [1, 2, 3, 4, 5]
    ]
]);

More info here: https://docs.phalcon.io/en/latest/reference/models.html#binding-parameters scroll little further after first two code sections;



23.6k

Are you talking about IN clause?

$robots = Robots::find([
  'id IN ({ids:array})',
  'bind' => [
      'ids' => [1, 2, 3, 4, 5]
  ]
]);

More info here: https://docs.phalcon.io/en/latest/reference/models.html#binding-parameters scroll little further after first two code sections;

Thanks friend, I was searching in docs but obviously not a nuff :D