Update database.php
This commit is contained in:
parent
5c3a5c8608
commit
4ee2a1128d
|
@ -214,13 +214,13 @@ if(!check_function_exists("exec_db_query")) {
|
||||||
return $flag;
|
return $flag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!check_function_exists("exec_db_fetch_all")) {
|
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;
|
|
||||||
|
$size = 0;
|
||||||
$is_not_countable = false;
|
$is_not_countable = false;
|
||||||
|
|
||||||
$rows = array();
|
$rows = array();
|
||||||
$stmt = get_db_stmt($sql, $bind);
|
$stmt = get_db_stmt($sql, $bind);
|
||||||
|
|
||||||
|
@ -229,11 +229,13 @@ if(!check_function_exists("exec_db_fetch_all")) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(array_key_equals("do_count", $options, true)) {
|
if(array_key_equals("do_count", $options, true)) {
|
||||||
$count_sql = sprintf("select count(*) as cnt from (%s) a", get_db_binded_sql($sql, $bind));
|
$_sql = sprintf("select count(*) as cnt from (%s) a", get_db_binded_sql($sql, $bind));
|
||||||
$count_data = exec_db_fetch($count_sql);
|
$_data = exec_db_fetch($_sql);
|
||||||
$length = get_value_in_array("cnt", $count_data, $length);
|
$size = get_value_in_array("cnt", $_data, $size);
|
||||||
} elseif(array_key_equals("do_count", $options, "fn_count")) {
|
} elseif(array_key_equals("do_count", $options, "count")) {
|
||||||
$length = count($rows);
|
$size = count($rows);
|
||||||
|
} elseif(array_key_equals("do_count", $options, "PDOStatement::rowCount")) {
|
||||||
|
$size = $stmt->rowCount();
|
||||||
} else {
|
} else {
|
||||||
$response = $rows;
|
$response = $rows;
|
||||||
$is_not_countable = true;
|
$is_not_countable = true;
|
||||||
|
@ -241,7 +243,10 @@ if(!check_function_exists("exec_db_fetch_all")) {
|
||||||
|
|
||||||
if(!$is_not_countable) {
|
if(!$is_not_countable) {
|
||||||
$response = array(
|
$response = array(
|
||||||
"length" => $length,
|
"length" => $size, // compatible with RSF 1.4 or lower
|
||||||
|
"size" => $size, // use RSF 1.5 or above (recommended: size)
|
||||||
|
"cnt" => $size,
|
||||||
|
"count" => $size,
|
||||||
"data" => $rows,
|
"data" => $rows,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user