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