Trying to a run a simple select query with WHERE IN on a couple ID's.
$idArray = array(492, 493, 494, 495);
$csvList = implode(",", $idArray);
DB::select("SELECT id, name FROM table WHERE id IN (?)", array($csvList));
That's what I'm running, no errors. The problem is, my query outputs $csvList
as a string with quotes. '492, 493, 494, 495'
which MySQL does not interpret properly. I only get 1 result back for 492
instead of all 4 results. If I remove the quotes from the query, it works fine.
This is the full query that runs with the page:
SELECT id, name FROM table WHERE id IN ('491,493,494,495');
I need to get rid of the quotes, anyone know how I can do that? Or what I'm doing wrong?