Skip to content

Instantly share code, notes, and snippets.

Last active Oct 24, 2019
What would you like to do?
Dynamically binding params in prepared statment
$array = [1,2,3,4,5,6,7];
$count_array = count($array);
$placeholders = implode(',', array_fill(0, $count_array, '?'));
$query = $DB->Prepare('
SELECT id, name
FROM table_name
WHERE id IN (' . $placeholders . ')
$list = $DB->GetAll($query, $array );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment