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 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?



67.7k
Accepted
answer

Hi,

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

https://forum.phalconphp.com/discussion/8755/executequery-with-bind-in-where



1.0k

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



1.0k

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