Hi,
Is there a way to bind an array to a placeholder parameter in a "IN" condition of a SQL query the same way as you bind other types?
For example, this works:
$value='something';
$sql="SELECT * FROM sometable WHERE someattr=:value";
$params=array(':value'=>$value);
$somemodel->findAllBySql($sql, $params);
However, this won’t work:
$values=array('foo', 'bar', 'boo');
$sql="SELECT * FROM sometable WHERE someattr IN (:values)";
$params=array(':values'=>$values);
$somemodel->findAllBySql($sql, $params);
How do I do that?
Or is it impossible at all to bind an array to a prepared statement?
I know I can do
$sql="SELECT * FROM sometable WHERE someattr IN (".implode(',',$values).")";
and forget the $params, but I’m looking for the elegant way.
thanks
m.