Update database.php

This commit is contained in:
Namhyeon Go 2019-02-26 11:03:30 +09:00 committed by GitHub
parent 82e35e0ee3
commit 7ab5dfb706
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -79,25 +79,25 @@ if(!function_exists("get_dbc_object")) {
} }
} }
// 2018-08-19: support lower php version (not supported anonymous function) if(!function_exists("get_db_binded_param")) {
if(!function_exists("compare_db_key_length")) { function get_db_binded_param($expression, $bind) {
function compare_db_key_length($a, $b) { foreach($bind as $k=>$v) {
return strlen($b) - strlen($a); if($expression == (":" . $k)) {
$expression = sprintf("'%s'", make_safe_argument($v));
}
}
return $expression;
} }
} }
if(!function_exists("get_db_binded_sql")) { if(!function_exists("get_db_binded_sql")) {
function get_db_binded_sql($sql, $bind) { function get_db_binded_sql($sql, $bind) {
if(count($bind) > 0) { $d = explode(" ", $sql);
$bind_keys = array_keys($bind); foreach($d as $k=>$v) {
$d[$k] = get_db_binded_param($v, $bind);
// 2018-08-19: support lower php version (not supported anonymous function)
usort($bind_keys, "compare_db_key_length");
foreach($bind_keys as $k) {
$sql = str_replace(":" . $k, "'" . make_safe_argument($bind[$k]) . "'", $sql);
}
} }
$sql = implode(" ", $d);
return $sql; return $sql;
} }