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

How to make select using IN ()

Is there any way to do something like that:


Robots::find(array(
    'type IN (:type:)',
    'bind' => array('type' => array(1, 2, 3))
));

in this case it fails as frong param count, but in


Robots::find(array(
    'type IN (:type:)',
    'bind' => array('type' => implode(', ', array(1, 2, 3)))
));

it return bad results, any ideas how to do this correctly?



85.5k
Accepted
answer

Hi,

you can't do it like that, here you can check my answers

https://forum.phalcon.io/discussion/8755/executequery-with-bind-in-where

Yeap, i knew about query builder and inWhere, but was interested is tehre any other way to do that. Thanks for answer

Well first of all, 'bind => array('type' => array(1, 2, 3))' is actually string.....

What version of Phalcon are you using? Your snippet must work in latest Phalcon 2.0.x

2.0.6 and in implode case it returns just first element

What version of Phalcon are you using? Your snippet must work in latest Phalcon 2.0.x