Update database.php

This commit is contained in:
Namhyeon Go 2019-04-01 16:53:58 +09:00 committed by GitHub
parent 49520296be
commit 1c922bc4b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -221,20 +221,20 @@ if(!check_function_exists("exec_db_query")) {
if(!check_function_exists("exec_db_fetch_all")) {
function exec_db_fetch_all($sql, $bind=array(), $options=array()) {
$response = array();
$length = 0;
$rows = array();
$stmt = get_db_stmt($sql, $bind);
if($stmt->execute() && $stmt->rowCount() > 0) {
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
}
// Count rows
$count_data = exec_db_fetch(sprintf("select count(*) as cnt from (%s)", $sql));
$length = get_value_in_array("cnt", $count_data, $length);
if(array_key_equals("do_count", $options, true)) {
$count_sql = sprintf("select count(*) as cnt from (%s) a", $sql);
$count_data = exec_db_fetch($count_sql);
$length = get_value_in_array("cnt", $count_data, $length);
$response = array(
"length" => $length,
"data" => $rows,