Update database.php

This commit is contained in:
Namhyeon Go 2018-08-19 05:09:26 +09:00 committed by GitHub
parent 8967a6ed1c
commit d7b14ae7aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -60,14 +60,20 @@ if(!function_exists("get_dbc_object")) {
} }
} }
// 2018-08-19: support lower php version (not supported anonymous function)
if(!function_exists("compare_db_key_length")) {
function compare_db_key_length($a, $b) {
return strlen($b) - strlen($a);
}
}
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) { if(count($bind) > 0) {
$bind_keys = array_keys($bind); $bind_keys = array_keys($bind);
usort($bind_keys, function($a, $b) { // 2018-08-19: support lower php version (not supported anonymous function)
return strlen($b) - strlen($a); usort($bind_keys, "compare_db_key_length");
});
foreach($bind_keys as $k) { foreach($bind_keys as $k) {
$sql = str_replace(":" . $k, "'" . addslashes($bind[$k]) . "'", $sql); $sql = str_replace(":" . $k, "'" . addslashes($bind[$k]) . "'", $sql);