I'm probably missing something obvious but does anyone know how to pass an array of values for a particular parameter to a prepared statement?
I would like to:
$sql = 'SELECT * FROM whatever WHERE id IN (?)';
$stmt = $pdo->prepare($sql);
$ids = array(1,2,3);
$stmt->execute(array($ids));
But instead I have to quote each id individually and build a comma separated string and then insert the string directly into my sql statement. I can't even pass the string as a parameter because it would end up being quoted as well.
This seems to negate at least some of the value of prepared statements.