I found this code on SO, which is great for using PDO and the IN() statement together.
$values = explode(\',\', $values) ; # 1,4,7
$placeholders = rtrim(str
This should work, if $values
is an array:
$query = "SELECT * FROM table WHERE id IN ($placeholders) AND product=?";
$stm->execute(array_merge($values, array($product)));
execute()
expects one parameter - in this case an array - to be provided. By adding array_merge($values, array($product))
you create one array with $product
added at the end, so the query should work correctly.
See the demo here: http://ideone.com/RcClX