From 6dea7e0502e29b4af920853d73825037e67e71ec Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Tue, 27 Mar 2018 10:57:57 +0900 Subject: [PATCH] Update database.php --- system/database.php | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/system/database.php b/system/database.php index a09fa89..f0d3cf7 100644 --- a/system/database.php +++ b/system/database.php @@ -47,21 +47,27 @@ if(!function_exists("get_dbc_object")) { } } -if(!function_exists("get_db_stmt")) { - function get_db_stmt($sql, $bind=array(), $bind_pdo=false, $show_sql=false) { - if(!$bind_pdo) { - if(count($bind) > 0) { - $bind_keys = array_keys($bind); +if(!function_exists("get_binded_sql")) { + function get_binded_sql($sql, $bind) { + if(count($bind) > 0) { + $bind_keys = array_keys($bind); - usort($bind_keys, function($a, $b) { - return strlen($b) - strlen($a); - }); + usort($bind_keys, function($a, $b) { + return strlen($b) - strlen($a); + }); - foreach($bind_keys as $k) { - $sql = str_replace(":" . $k, "'" . addslashes($bind[$k]) . "'", $sql); - } + foreach($bind_keys as $k) { + $sql = str_replace(":" . $k, "'" . addslashes($bind[$k]) . "'", $sql); } } + + return $sql; + } +} + +if(!function_exists("get_db_stmt")) { + function get_db_stmt($sql, $bind=array(), $bind_pdo=false, $show_sql=false) { + $sql = !$bind_pdo ? get_binded_sql($sql, $bind) : $sql; $stmt = get_dbc_object()->prepare($sql); if($show_sql) {