Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

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?



83.4k
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')
));


9.4k

ok, got it.