mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
MDL-40266 improve emulate_bound_params() for mysqli
Looping over large numbers of items with array_shift() is expensive. Reverse the array and fetch items from the top of the pile.
This commit is contained in:
parent
f0d37f4ac5
commit
4f3e38e745
1 changed files with 3 additions and 3 deletions
|
@ -853,8 +853,8 @@ class mysqli_native_moodle_database extends moodle_database {
|
||||||
return $sql;
|
return $sql;
|
||||||
}
|
}
|
||||||
// ok, we have verified sql statement with ? and correct number of params
|
// ok, we have verified sql statement with ? and correct number of params
|
||||||
$parts = explode('?', $sql);
|
$parts = array_reverse(explode('?', $sql));
|
||||||
$return = array_shift($parts);
|
$return = array_pop($parts);
|
||||||
foreach ($params as $param) {
|
foreach ($params as $param) {
|
||||||
if (is_bool($param)) {
|
if (is_bool($param)) {
|
||||||
$return .= (int)$param;
|
$return .= (int)$param;
|
||||||
|
@ -868,7 +868,7 @@ class mysqli_native_moodle_database extends moodle_database {
|
||||||
$param = $this->mysqli->real_escape_string($param);
|
$param = $this->mysqli->real_escape_string($param);
|
||||||
$return .= "'$param'";
|
$return .= "'$param'";
|
||||||
}
|
}
|
||||||
$return .= array_shift($parts);
|
$return .= array_pop($parts);
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue