|
|
|
@ -106,36 +106,36 @@ class PdoWrapper extends PDO
|
|
|
|
|
protected function processInStatementSql(string $sql, array $params = []): array
|
|
|
|
|
{
|
|
|
|
|
// Replace "IN(?)" with "IN(?,?,?)"
|
|
|
|
|
$sql = preg_replace('/IN\s*\(\s*\?\s*\)/i', 'IN(?)', $sql);
|
|
|
|
|
$sql = preg_replace('/IN\s*\(\s*\?\s*\)/i', 'IN(?)', $sql);
|
|
|
|
|
|
|
|
|
|
$current_index = 0;
|
|
|
|
|
while (($current_index = strpos($sql, 'IN(?)', $current_index)) !== false) {
|
|
|
|
|
$preceeding_count = substr_count($sql, '?', 0, $current_index - 1);
|
|
|
|
|
$current_index = 0;
|
|
|
|
|
while (($current_index = strpos($sql, 'IN(?)', $current_index)) !== false) {
|
|
|
|
|
$preceeding_count = substr_count($sql, '?', 0, $current_index - 1);
|
|
|
|
|
|
|
|
|
|
$param = $params[$preceeding_count];
|
|
|
|
|
$question_marks = '?';
|
|
|
|
|
$param = $params[$preceeding_count];
|
|
|
|
|
$question_marks = '?';
|
|
|
|
|
|
|
|
|
|
if (is_string($param) || is_array($param)) {
|
|
|
|
|
$params_to_use = $param;
|
|
|
|
|
if (is_string($param)) {
|
|
|
|
|
$params_to_use = explode(',', $param);
|
|
|
|
|
}
|
|
|
|
|
if (is_string($param) || is_array($param)) {
|
|
|
|
|
$params_to_use = $param;
|
|
|
|
|
if (is_string($param)) {
|
|
|
|
|
$params_to_use = explode(',', $param);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach ($params_to_use as $key => $value) {
|
|
|
|
|
if (is_string($value)) {
|
|
|
|
|
$params_to_use[$key] = trim($value);
|
|
|
|
|
foreach ($params_to_use as $key => $value) {
|
|
|
|
|
if (is_string($value)) {
|
|
|
|
|
$params_to_use[$key] = trim($value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$question_marks = join(',', array_fill(0, count($params_to_use), '?'));
|
|
|
|
|
$sql = substr_replace($sql, $question_marks, $current_index + 3, 1);
|
|
|
|
|
$question_marks = join(',', array_fill(0, count($params_to_use), '?'));
|
|
|
|
|
$sql = substr_replace($sql, $question_marks, $current_index + 3, 1);
|
|
|
|
|
|
|
|
|
|
array_splice($params, $preceeding_count, 1, $params_to_use);
|
|
|
|
|
}
|
|
|
|
|
array_splice($params, $preceeding_count, 1, $params_to_use);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$current_index += strlen($question_marks) + 4;
|
|
|
|
|
}
|
|
|
|
|
$current_index += strlen($question_marks) + 4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return [ 'sql' => $sql, 'params' => $params ];
|
|
|
|
|
return [ 'sql' => $sql, 'params' => $params ];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|