From 00a6f4905c58afea0e03852ff50c266dc3464095 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=8B=E8=BE=B0=E8=BD=A9?= Date: Fri, 17 May 2024 17:16:15 +0800 Subject: [PATCH] * Change 1027 sql, adjust querySQL function. --- module/bi/config/pivots.php | 15 ++++++++++++--- module/bi/model.php | 9 +++++---- 2 files changed, 17 insertions(+), 7 deletions(-) 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); } /**