diff --git a/module/bi/config/pivots.php b/module/bi/config/pivots.php index 974aea8e17..e36a7ae903 100644 --- a/module/bi/config/pivots.php +++ b/module/bi/config/pivots.php @@ -1626,7 +1626,8 @@ select day,null as actions,null as userlogin,null as consumed,null as storyopen, union all select day,null as actions,null as userlogin,null as consumed,null as storyopen,null as storyclose,null as taskopen,null as taskfinish,null as bugopen,bugresolve from ztv_daybugresolve ) as uniontable -where if(\$startDate='',1,day>=\$startDate) and if(\$endDate='',1,day<=\$endDate) +where (case when \$startDate='' then 1 else day>=\$startDate end) +and (case when \$endDate='' then 1 else day<=\$endDate end) group by day EOT, 'settings' => array @@ -1884,10 +1885,18 @@ $config->bi->builtin->pivots[] = array 'dimension' => '1', 'group' => '60,61', 'sql' => << array ( diff --git a/module/bi/model.php b/module/bi/model.php index 979d8c4644..a343b04691 100644 --- a/module/bi/model.php +++ b/module/bi/model.php @@ -92,12 +92,13 @@ class biModel extends model if($driverName == 'mysql') { $rows = $dbh->query($limitSql)->fetchAll(); - $rowsCount = $dbh->query("SELECT FOUND_ROWS() as count")->fetch(); + $rowsCount = $dbh->query("SELECT FOUND_ROWS() as count")->fetch('count'); } elseif($driverName == 'duckdb') { - $rows = $dbh->query($sql)->fetchAll(); - $rowsCount = count($rows); + $rows = $dbh->query($limitSql)->fetchAll(); + $allRows = $dbh->query($sql)->fetchAll(); + $rowsCount = count($allRows); } } catch(Exception $e) @@ -107,7 +108,7 @@ class biModel extends model return array('result' => 'fail', 'message' => $message); } - return array('result' => 'success', 'rows' => $rows, 'rowCount' => $rowCount); + return array('result' => 'success', 'rows' => $rows, 'rowsCount' => $rowsCount); } /**