From c030fe1fbaf61c944f545367e8be5ad58fec520e Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Mon, 19 Mar 2018 02:27:05 +0900 Subject: [PATCH] Update database.php --- system/database.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/system/database.php b/system/database.php index 1ad7afd..f64d1c3 100644 --- a/system/database.php +++ b/system/database.php @@ -132,7 +132,7 @@ if(!function_exists("exec_db_fetch_all")) { 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); } @@ -141,6 +141,24 @@ if(!function_exists("exec_db_fetch_all")) { } } +if(!function_exists("exec_db_fetch")) { + function exec_db_fetch($sql, $bind=array(), $bind_limit=true) { + $row = NULL; + $rows = array(); + + if($bind_limit == true) { + $sql = $sql . " limit 1"; + } + + $rows = exec_db_fetch_all($sql, $bind); + if(count($rows) > 0) { + $row = $rows[0]; + } + + return $row; + } +} + if(!function_exists("get_page_range")) { function get_page_range($page=1, $limit=0) { $append_sql = "";