Imagine I have the following SQL query:
SELECT id,name FROM user WHERE id IN ('id1','id2','id3')
Now imagine I need the array of ids to be supplied by PHP. So I have something like this:
$idList = array('id1','id2','id3');
$query = "SELECT id,name FROM user WHERE id IN (?)";
$stmt = $db->prepare($query);
$stmt->bind_param(/*Something*/);
What can I replace /*Something*/ with to get the same results as the original query? Or do I need to put in 3 question marks in the query format? The only reason I don’t want to do that is because the number of question marks is variable, so I would have to build the query string manually.
No you cannot.
For your situation, you should build the query string programmatically. If you are guaranteed it will always be three values, you could add three markers to the SQL then bind via looping over the array.