Update database.php
This commit is contained in:
parent
da1f8f2f09
commit
2bf0f8b17b
|
@ -222,6 +222,7 @@ if(!check_function_exists("exec_db_fetch_all")) {
|
||||||
function exec_db_fetch_all($sql, $bind=array(), $options=array()) {
|
function exec_db_fetch_all($sql, $bind=array(), $options=array()) {
|
||||||
$response = array();
|
$response = array();
|
||||||
$length = 0;
|
$length = 0;
|
||||||
|
$is_not_countable = false;
|
||||||
|
|
||||||
$rows = array();
|
$rows = array();
|
||||||
$stmt = get_db_stmt($sql, $bind);
|
$stmt = get_db_stmt($sql, $bind);
|
||||||
|
@ -234,13 +235,18 @@ if(!check_function_exists("exec_db_fetch_all")) {
|
||||||
$count_sql = sprintf("select count(*) as cnt from (%s) a", $sql);
|
$count_sql = sprintf("select count(*) as cnt from (%s) a", $sql);
|
||||||
$count_data = exec_db_fetch($count_sql);
|
$count_data = exec_db_fetch($count_sql);
|
||||||
$length = get_value_in_array("cnt", $count_data, $length);
|
$length = get_value_in_array("cnt", $count_data, $length);
|
||||||
|
} elseif(array_key_equals("do_count", $options, "function_count")) {
|
||||||
|
$length = count($rows);
|
||||||
|
} else {
|
||||||
|
$response = $rows;
|
||||||
|
$is_not_countable = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$is_not_countable) {
|
||||||
$response = array(
|
$response = array(
|
||||||
"length" => $length,
|
"length" => $length,
|
||||||
"data" => $rows,
|
"data" => $rows,
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
$response = $rows;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user