How would you write a prepared MySQL statement in PHP that takes a differing number of arguments each time. An example such query is:
SELECT
age
, name
FROM people
WHERE id IN (12, 45, 65, 33)
The IN CLAUSE will have a different number of id's each time it is run.
I have two possible solutions in my mind but want to see if there is a better way.
Possible Solution 1 Make the statement accept 100 variables and fill the rest with dummy values guaranteed not to be in the table, make multiple calls for more than 100 values.
Possible Solution 2 Don't use a prepared statement, build and run the query checking stringently for possible injection attacks.