From ac6cba6e50cfc1754a5bed03422760dc15cef442 Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Tue, 13 Feb 2018 16:37:27 +0900 Subject: [PATCH] Update database.php --- system/database.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/system/database.php b/system/database.php index 2efc0bb..f82fb9e 100644 --- a/system/database.php +++ b/system/database.php @@ -13,16 +13,7 @@ $conn->query("SET NAMES 'utf8'"); if(!function_exists("sql_query")) { function sql_query($sql, $bind=array()) { - global $conn; - - $stmt = $conn->prepare($sql); - if(count($bind) > 0) { - foreach($bind as $k=>$v) { - $stmt->bindParam(':' . $k, $v); - } - } - - return $stmt; + return get_db_stmt($sql, $bind); } } @@ -81,5 +72,16 @@ function exec_db_query($sql, $bind=array(), $options=array()) { return $flag; } +function exec_db_fetch_all($sql, $bind=array()) { + $rows = array(); + $stmt = get_db_stmt($sql, $bind); + + if($stmt->execute() && $stmt->rowCount() > 0) { + $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); + } + + return $rows; +} + // set global db connection variable $dbc = get_db_connect();