I want to prepare a statement for use inside a loop. When I try to execute the statement I see an error in the logs saying “Invalid parameter number: no parameters were bound'”.
What’s wrong with my code?
$itemSelectSql = "SELECT * FROM `tblItems` WHERE `itemID` IN (?)";
$itemSelectStmt = new Zend_Db_Statement_Mysqli($this->db_ro, $itemSelectSql);
while () {
...
$itemIds = array();
// populate $itemIds array
...
$itemSelectStmt->execute(array($itemIds));
}
EDIT:
I think I may have a bug in my set up which explains why whatever I try fails. I’m seeing this:
PHP Warning: call_user_func_array() expects parameter 1 to be a valid callback,
class 'PDOStatement' does not have a method 'bind_param' in
/var/www/lib/Zend/Db/Statement/Mysqli.php on line 204
EDIT:
I was using the wrong adapter. Should have been Zend_Db_Statement_Pdo 🙂
Thanks for the replies.
?can’t be replaced by an array, it has to be replaced by a scalar (thanks to comment for pointing out that this does not always mean string… brain-fart on my end). Let me know if this works better: