I have a comma separated array of ids stored in a string that looks like this :
$array_string = "4,6,15,94,122,145";
I'm trying to query the database to return results based on these ids but I'm only getting results for the first id in the string, the rest are being ignored.
$sql = 'SELECT * FROM table WHERE user_id IN (:array) ORDER BY last_updated DESC';
$db = static::getDB();
$stmt = $db->prepare($sql);
$stmt->bindParam(':array', $array_string, PDO::PARAM_STR);
$stmt->execute();
return $stmt->fetchAll(PDO::FETCH_OBJ);
This will only return results for id 4
and none of the others. What am I doing wrong?