I have a list of integer ID's that correspond to rows in the database, and I need to get out the specific rows for a specific set of ID's. My query would be as follows:
SELECT id, name FROM locations WHERE ID in (1,4,5,7,8,...)
I could do this by imploding the list into a comma separated string, but this would not be safe from SQL injection. Is there a way, using prepared statements, to bind a list of integers?
If not, would a suitable workaround be to check that each item in the list is numeric, and only then proceeding with the query?