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 user IN condition in Model::find()? and what about the param binding?

The code below is not working

Robots::find(array(
    'robot_id IN :ids:',
    'bind'=>array('123','321','111')
));

how to use the IN statement and bind params properly?



98.9k
Accepted
answer

PDO does not support bind arrays directly, you have to pass each value independently:

Robots::find(array(
    'robot_id IN (?0, ?1, ?2)',
    'bind'=>array('123','321','111')
));


17.8k

ok, got it.