Looping over large numbers of items with array_shift() is expensive.
Reverse the array and fetch items from the top of the pile.
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;
$param = $this->mysqli->real_escape_string($param);
$return .= "'$param'";
}
- $return .= array_shift($parts);
+ $return .= array_pop($parts);
}
return $return;
}