Update xml_cdr_inc.php

Only check the select count if there is a default setting that instructs it to do so as it is slow on a large number of records.
This commit is contained in:
FusionPBX
2016-06-11 07:15:11 -06:00
committed by GitHub
parent 5c7fcd1d9e
commit c6b15a6537

View File

@@ -273,25 +273,31 @@ else {
//page results if rows_per_page is greater than zero
if ($rows_per_page > 0) {
//get the number of rows in the v_xml_cdr
$sql = "select count(*) as num_rows from v_xml_cdr ";
$sql .= "where domain_uuid = '".$domain_uuid."' ".$sql_where;
$prep_statement = $db->prepare(check_sql($sql));
if ($prep_statement) {
$prep_statement->execute();
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
if ($row['num_rows'] > 0) {
$num_rows = $row['num_rows'];
}
else {
$num_rows = '0';
}
if ($_SESSION['cdr']['count']['boolean'] == "true") {
//get the number of rows in the v_xml_cdr
$sql = "select count(*) as num_rows from v_xml_cdr ";
$sql .= "where domain_uuid = '".$domain_uuid."' ".$sql_where;
$prep_statement = $db->prepare(check_sql($sql));
if ($prep_statement) {
$prep_statement->execute();
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
if ($row['num_rows'] > 0) {
$num_rows = $row['num_rows'];
}
else {
$num_rows = '0';
}
}
unset($prep_statement, $result);
}
unset($prep_statement, $result);
//limit the number of results
if ($num_rows > $_SESSION['cdr']['limit']['numeric']) {
$num_rows = $_SESSION['cdr']['limit']['numeric'];
else {
//limit the number of results
if ($num_rows > $_SESSION['cdr']['limit']['numeric']) {
$num_rows = $_SESSION['cdr']['limit']['numeric'];
}
else {
$num_rows = '1000';
}
}
if ($_SESSION['domain']['paging']['numeric'] != '' && $rows_per_page > $_SESSION['domain']['paging']['numeric']) {
$rows_per_page = $_SESSION['domain']['paging']['numeric'];