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 = "";