Last active
October 24, 2019 06:04
-
-
Save nd3w/237f8a0c886fa225fc058a57b161e289 to your computer and use it in GitHub Desktop.
Dynamically binding params in prepared statment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$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