Re: ZF2 - Zend\Db and IN (1,2,3,4,5) only printing out IN (1)
Hey, I'm not sure if this is caused by the same issue or not but I'm also running into a similar problem with 'IN' when doing query() and execute() for array IN parameters.
I had a little google and look around stackoverflow and I think it's a common problem anyway?
$idList = array(1,2);
$sql = "SELECT * FROM table WHERE id IN (" . $fp('idList') . ")";
$statement = $adapter->query($sql);
$rowSet = $statement->execute(array(
'idList' => $idList
I tried a few bits and bobs but it seems the only way I can get this to work is to implode the values directly into the SQL which defeats the whole purpose of prepare, execute. Is there actually any way to send in array parameters for IN within MySQL etc anyway? I would have thought in MySQL that the following would use the same query plan anyway:
SELECT * FROM table WHERE id IN (1)
SELECT * FROM table WHERE id IN (1,2,3)
SELECT * FROM table WHERE id IN (1,2,3,4,5,6,7,8,9,10);
Thanks to you guys I've only just learnt about the benefits of prepare, execute as before ZF I was using mysql_query.... so I guess I don't know enough about what's going on yet :D