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

WHERE IN clause

Guys, why this returns me only first (1) record?

$types = '1,2,3';
$estateTypes = EstateType::find(array(
    'conditions' => 'id IN (?1)',
    'bind' => (array(1 => $types))
));

If I use it like this

$estateTypes = EstateType::find(array(
    'conditions' => 'id IN (1,2,3)'
));

it returns all records matched.



98.9k
Accepted
answer

Because a single value is being bound, this is the same as:

$estateTypes = EstateType::find(array(
    'conditions' => 'id IN ("1,2,3")'
));


19.2k

My mistake... Looks like it's too late for coding, gonna sleep a while :) Thanks @Phalcon