mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
MDL-40266 improve emulate_bound_params() for sqlsrv driver
Looping over large numbers of items with array_shift() is expensive. Reverse the array and fetch items from the top of the pile. Credit goes to Martin Langhoff for original mysqli fix.
This commit is contained in:
parent
f0d37f4ac5
commit
b983901d48
@ -625,8 +625,8 @@ class mssql_native_moodle_database extends moodle_database {
|
||||
return $sql;
|
||||
}
|
||||
// ok, we have verified sql statement with ? and correct number of params
|
||||
$parts = explode('?', $sql);
|
||||
$return = array_shift($parts);
|
||||
$parts = array_reverse(explode('?', $sql));
|
||||
$return = array_pop($parts);
|
||||
foreach ($params as $param) {
|
||||
if (is_bool($param)) {
|
||||
$return .= (int)$param;
|
||||
@ -651,7 +651,7 @@ class mssql_native_moodle_database extends moodle_database {
|
||||
$return .= "N'$param'";
|
||||
}
|
||||
|
||||
$return .= array_shift($parts);
|
||||
$return .= array_pop($parts);
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user