* [misc] replace COUNT(*) with COUNT(1) in sql.

This commit is contained in:
liugang
2024-06-27 14:07:27 +08:00
committed by 王于听
parent 250b4914a8
commit a4d2de38f0
43 changed files with 150 additions and 150 deletions
+2 -2
View File
@@ -240,7 +240,7 @@ class reportsEntry extends entry
$this->app->loadLang('product');
$this->app->loadLang('story');
$storyStatusStat = $this->dao->select('t1.product,t2.name,t2.status,t1.status as storyStatus,count(*) as storyCount')->from(TABLE_STORY)->alias('t1')
$storyStatusStat = $this->dao->select('t1.product, t2.name, t2.status, t1.status AS storyStatus, COUNT(1) AS storyCount')->from(TABLE_STORY)->alias('t1')
->leftJoin(TABLE_PRODUCT)->alias('t2')->on('t1.product=t2.id')
->where('t2.deleted')->eq(0)
->andWhere('t1.deleted')->eq(0)
@@ -312,7 +312,7 @@ class reportsEntry extends entry
$this->app->loadLang('product');
$this->app->loadLang('bug');
$bugStatusStat = $this->dao->select('t1.product,t2.name,t2.status,t1.status as bugStatus,count(*) as bugCount')->from(TABLE_BUG)->alias('t1')
$bugStatusStat = $this->dao->select('t1.product, t2.name, t2.status, t1.status AS bugStatus, COUNT(1) AS bugCount')->from(TABLE_BUG)->alias('t1')
->leftJoin(TABLE_PRODUCT)->alias('t2')->on('t1.product=t2.id')
->where('t2.deleted')->eq(0)
->andWhere('t1.deleted')->eq(0)
+8 -8
View File
@@ -20,8 +20,8 @@ CREATE FUNCTION qc_cminited($project int, $category varchar(30)) returns int
begin
declare products int default 0__DELIMITER__
declare objects int default 0__DELIMITER__
select count(*) from zt_projectproduct where project = $project into products__DELIMITER__
select count(distinct product) from zt_object where project = $project and category = $category and type = 'taged' and product in (select product from zt_projectproduct where project = $project) into objects__DELIMITER__
select COUNT(1) from zt_projectproduct where project = $project into products__DELIMITER__
select COUNT(DISTINCT product) from zt_object where project = $project and category = $category and type = 'taged' and product in (select product from zt_projectproduct where project = $project) into objects__DELIMITER__
IF products = objects THEN
return 1__DELIMITER__
ELSEIF products != objects THEN
@@ -98,9 +98,9 @@ DROP FUNCTION IF EXISTS `qc_pgmallrequirementstage`;
CREATE FUNCTION `qc_pgmallrequirementstage`($project int) RETURNS int(1)
BEGIN
-- 获取项目产品总数
select count(*) as products from zt_projectproduct where project = $project into @totalproduct__DELIMITER__
select COUNT(1) AS products from zt_projectproduct where project = $project into @totalproduct__DELIMITER__
-- 获取已经设置需求阶段的产品总数
select count(*) as product from (select product from zt_projectproduct where project in (select id from zt_project where project = $project and type = 'stage' and attribute = 'request' and deleted = '0') GROUP BY product) as product into @product__DELIMITER__
select COUNT(1) AS product from (select product from zt_projectproduct where project in (select id from zt_project where project = $project and type = 'stage' and attribute = 'request' and deleted = '0') GROUP BY product) as product into @product__DELIMITER__
-- 让项目产品总数和已设置需求阶段产品总数比较,都设置返回1,否则返回0
if @totalproduct = @product then return 1__DELIMITER__
end if__DELIMITER__
@@ -153,9 +153,9 @@ DROP FUNCTION IF EXISTS `qc_pgmspecifiedtypeactualdays`;
CREATE FUNCTION `qc_pgmspecifiedtypeactualdays`($project int,$attribute varchar(50)) RETURNS int(10)
BEGIN
-- 查询某类型的阶段总数
select count(*) from zt_project where project = $project and attribute = $attribute and deleted = '0' and id not in (select parent from zt_project where project = $project and attribute = $attribute and grade = 2 group by parent) into @totalstory__DELIMITER__
select COUNT(1) from zt_project where project = $project and attribute = $attribute and deleted = '0' and id not in (select parent from zt_project where project = $project and attribute = $attribute and grade = 2 group by parent) into @totalstory__DELIMITER__
-- 查询某类型已设置实际工期的阶段总数
select count(*) from zt_project where project = $project and attribute = $attribute and deleted = '0' and realDuration > 0 and id not in (select parent from zt_project where project = $project and attribute = $attribute and grade = 2 group by parent) into @setstory__DELIMITER__
select COUNT(1) from zt_project where project = $project and attribute = $attribute and deleted = '0' and realDuration > 0 and id not in (select parent from zt_project where project = $project and attribute = $attribute and grade = 2 group by parent) into @setstory__DELIMITER__
-- 查询项目下某类型阶段实际工期总数
select sum(realDuration) as realDuration from zt_project where project = $project and attribute = $attribute and deleted = '0' and realDuration > 0 and id not in (select parent from zt_project where project = $project and attribute = $attribute and grade = 2 group by parent) into @days__DELIMITER__
-- 判断项目下某类型的阶段是否都已设置实际工期
@@ -176,9 +176,9 @@ DROP FUNCTION IF EXISTS `qc_pgmstageactualduration`;
CREATE FUNCTION `qc_pgmstageactualduration`($product int, $attribute varchar(50)) RETURNS int(10)
BEGIN
-- 查找某类型的阶段总数
select count(*) as totalduration from zt_project where id in (select project from zt_projectproduct where product = $product) and type = 'stage' and attribute = $attribute and deleted = '0' and id not in (select parent from zt_project where id in (select project from zt_projectproduct where product = $product) and attribute = $attribute and grade = 2 group by parent) into @totalduration__DELIMITER__
select COUNT(1) as totalduration from zt_project where id in (select project from zt_projectproduct where product = $product) and type = 'stage' and attribute = $attribute and deleted = '0' and id not in (select parent from zt_project where id in (select project from zt_projectproduct where product = $product) and attribute = $attribute and grade = 2 group by parent) into @totalduration__DELIMITER__
-- 查某类型阶段已设置实际工期的总数
select count(*) as setduration from zt_project where id in (select project from zt_projectproduct where product = $product) and type = 'stage' and attribute = $attribute and deleted = '0' and id not in (select parent from zt_project where id in (select project from zt_projectproduct where product = $product) and attribute = $attribute and grade = 2 group by parent) and realDuration > 0 into @setduration__DELIMITER__
select COUNT(1) as setduration from zt_project where id in (select project from zt_projectproduct where product = $product) and type = 'stage' and attribute = $attribute and deleted = '0' and id not in (select parent from zt_project where id in (select project from zt_projectproduct where product = $product) and attribute = $attribute and grade = 2 group by parent) and realDuration > 0 into @setduration__DELIMITER__
-- 指定产品下某类型的阶段实际工期总和
select sum(realDuration) as duration from zt_project where id in (select project from zt_projectproduct where product = $product) and type = 'stage' and attribute = $attribute and deleted = '0' and id not in (select parent from zt_project where id in (select project from zt_projectproduct where product = $product) and attribute = $attribute and grade = 2 group by parent) and realDuration > 0 into @duration__DELIMITER__
-- 需要判断该类型阶段都已设置实际工期,否则不统计
+15 -15
View File
@@ -471,22 +471,22 @@ CREATE TABLE IF NOT EXISTS `zt_report` (
UNIQUE KEY `code` (`code`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE OR REPLACE VIEW `ztv_executionsummary` AS select `zt_task`.`execution` AS `execution`,sum(if((`zt_task`.`parent` >= '0'),`zt_task`.`estimate`,0)) AS `estimate`,sum(if((`zt_task`.`parent` >= '0'),`zt_task`.`consumed`,0)) AS `consumed`,sum(if(((`zt_task`.`status` <> 'cancel') and (`zt_task`.`status` <> 'closed') and (`zt_task`.`parent` >= '0')),`zt_task`.`left`,0)) AS `left`,count(0) AS `number`,sum(if(((`zt_task`.`status` <> 'done') and (`zt_task`.`status` <> 'closed')),1,0)) AS `undone`,sum((if((`zt_task`.`parent` >= '0'),`zt_task`.`consumed`,0) + if(((`zt_task`.`status` <> 'cancel') and (`zt_task`.`status` <> 'closed') and (`zt_task`.`parent` >= '0')),`zt_task`.`left`,0))) AS `totalReal` from `zt_task` where (`zt_task`.`deleted` = '0') group by `zt_task`.`execution`;
CREATE OR REPLACE VIEW `ztv_projectsummary` AS select `zt_task`.`project` AS `project`,sum(if((`zt_task`.`parent` >= '0'),`zt_task`.`estimate`,0)) AS `estimate`,sum(if((`zt_task`.`parent` >= '0'),`zt_task`.`consumed`,0)) AS `consumed`,sum(if(((`zt_task`.`status` <> 'cancel') and (`zt_task`.`status` <> 'closed') and (`zt_task`.`parent` >= '0')),`zt_task`.`left`,0)) AS `left`,count(0) AS `number`,sum(if(((`zt_task`.`status` <> 'done') and (`zt_task`.`status` <> 'closed')),1,0)) AS `undone`,sum((if((`zt_task`.`parent` >= '0'),`zt_task`.`consumed`,0) + if(((`zt_task`.`status` <> 'cancel') and (`zt_task`.`status` <> 'closed') and (`zt_task`.`parent` >= '0')),`zt_task`.`left`,0))) AS `totalReal` from `zt_task` where (`zt_task`.`deleted` = '0') group by `zt_task`.`project`;
CREATE OR REPLACE VIEW `ztv_projectstories` AS select `t1`.`project` AS `execution`,count('*') AS `stories`,sum(if((`t2`.`status` = 'closed'),0,1)) AS `undone` from ((`zt_projectstory` `t1` left join `zt_story` `t2` on((`t1`.`story` = `t2`.`id`))) left join `zt_project` `t3` on((`t1`.`project` = `t3`.`id`))) where ((`t2`.`deleted` = '0') and (`t3`.`type` in ('sprint','stage'))) group by `t1`.`project`;
CREATE OR REPLACE VIEW `ztv_projectteams` AS select `zt_team`.`root` AS `execution`,count('*') AS `teams` from `zt_team` where (`zt_team`.`type` = 'execution') group by `zt_team`.`root`;
CREATE OR REPLACE VIEW `ztv_projectbugs` AS select `zt_bug`.`execution` AS `execution`,count(0) AS `bugs`,sum(if((`zt_bug`.`resolution` = ''),0,1)) AS `resolutions`,sum(if((`zt_bug`.`severity` <= 2),1,0)) AS `seriousBugs` from `zt_bug` where (`zt_bug`.`deleted` = '0') group by `zt_bug`.`execution`;
CREATE OR REPLACE VIEW `ztv_productbugs` AS select `zt_bug`.`product` AS `product`,count(0) AS `bugs`,sum(if((`zt_bug`.`resolution` = ''),0,1)) AS `resolutions`,sum(if((`zt_bug`.`severity` <= 2),1,0)) AS `seriousBugs` from `zt_bug` where (`zt_bug`.`deleted` = '0') group by `zt_bug`.`product`;
CREATE OR REPLACE VIEW `ztv_productstories` AS select `zt_story`.`product` AS `product`,count('*') AS `stories`,sum(if((`zt_story`.`status` = 'closed'),0,1)) AS `undone` from `zt_story` where (`zt_story`.`deleted` = '0') group by `zt_story`.`product`;
CREATE OR REPLACE VIEW `ztv_dayuserlogin` AS select count(*) AS `userlogin`,left(`zt_action`.`date`,10) AS `day` from `zt_action` where ((`zt_action`.`objectType` = 'user') and (`zt_action`.`action` = 'login')) group by left(`zt_action`.`date`,10);
CREATE OR REPLACE VIEW `ztv_executionsummary` AS select `zt_task`.`execution` AS `execution`,sum(if((`zt_task`.`parent` >= '0'),`zt_task`.`estimate`,0)) AS `estimate`,sum(if((`zt_task`.`parent` >= '0'),`zt_task`.`consumed`,0)) AS `consumed`,sum(if(((`zt_task`.`status` <> 'cancel') and (`zt_task`.`status` <> 'closed') and (`zt_task`.`parent` >= '0')),`zt_task`.`left`,0)) AS `left`,COUNT(1) AS `number`,sum(if(((`zt_task`.`status` <> 'done') and (`zt_task`.`status` <> 'closed')),1,0)) AS `undone`,sum((if((`zt_task`.`parent` >= '0'),`zt_task`.`consumed`,0) + if(((`zt_task`.`status` <> 'cancel') and (`zt_task`.`status` <> 'closed') and (`zt_task`.`parent` >= '0')),`zt_task`.`left`,0))) AS `totalReal` from `zt_task` where (`zt_task`.`deleted` = '0') group by `zt_task`.`execution`;
CREATE OR REPLACE VIEW `ztv_projectsummary` AS select `zt_task`.`project` AS `project`,sum(if((`zt_task`.`parent` >= '0'),`zt_task`.`estimate`,0)) AS `estimate`,sum(if((`zt_task`.`parent` >= '0'),`zt_task`.`consumed`,0)) AS `consumed`,sum(if(((`zt_task`.`status` <> 'cancel') and (`zt_task`.`status` <> 'closed') and (`zt_task`.`parent` >= '0')),`zt_task`.`left`,0)) AS `left`,COUNT(1) AS `number`,sum(if(((`zt_task`.`status` <> 'done') and (`zt_task`.`status` <> 'closed')),1,0)) AS `undone`,sum((if((`zt_task`.`parent` >= '0'),`zt_task`.`consumed`,0) + if(((`zt_task`.`status` <> 'cancel') and (`zt_task`.`status` <> 'closed') and (`zt_task`.`parent` >= '0')),`zt_task`.`left`,0))) AS `totalReal` from `zt_task` where (`zt_task`.`deleted` = '0') group by `zt_task`.`project`;
CREATE OR REPLACE VIEW `ztv_projectstories` AS select `t1`.`project` AS `execution`,COUNT(1) AS `stories`,sum(if((`t2`.`status` = 'closed'),0,1)) AS `undone` from ((`zt_projectstory` `t1` left join `zt_story` `t2` on((`t1`.`story` = `t2`.`id`))) left join `zt_project` `t3` on((`t1`.`project` = `t3`.`id`))) where ((`t2`.`deleted` = '0') and (`t3`.`type` in ('sprint','stage'))) group by `t1`.`project`;
CREATE OR REPLACE VIEW `ztv_projectteams` AS select `zt_team`.`root` AS `execution`,COUNT(1) AS `teams` from `zt_team` where (`zt_team`.`type` = 'execution') group by `zt_team`.`root`;
CREATE OR REPLACE VIEW `ztv_projectbugs` AS select `zt_bug`.`execution` AS `execution`,COUNT(1) AS `bugs`,sum(if((`zt_bug`.`resolution` = ''),0,1)) AS `resolutions`,sum(if((`zt_bug`.`severity` <= 2),1,0)) AS `seriousBugs` from `zt_bug` where (`zt_bug`.`deleted` = '0') group by `zt_bug`.`execution`;
CREATE OR REPLACE VIEW `ztv_productbugs` AS select `zt_bug`.`product` AS `product`,COUNT(1) AS `bugs`,sum(if((`zt_bug`.`resolution` = ''),0,1)) AS `resolutions`,sum(if((`zt_bug`.`severity` <= 2),1,0)) AS `seriousBugs` from `zt_bug` where (`zt_bug`.`deleted` = '0') group by `zt_bug`.`product`;
CREATE OR REPLACE VIEW `ztv_productstories` AS select `zt_story`.`product` AS `product`,COUNT(1) AS `stories`,sum(if((`zt_story`.`status` = 'closed'),0,1)) AS `undone` from `zt_story` where (`zt_story`.`deleted` = '0') group by `zt_story`.`product`;
CREATE OR REPLACE VIEW `ztv_dayuserlogin` AS select COUNT(1) AS `userlogin`,left(`zt_action`.`date`,10) AS `day` from `zt_action` where ((`zt_action`.`objectType` = 'user') and (`zt_action`.`action` = 'login')) group by left(`zt_action`.`date`,10);
CREATE OR REPLACE VIEW `ztv_dayeffort` AS select round(sum(`zt_effort`.`consumed`),1) AS `consumed`,`zt_effort`.`date` AS `date` from `zt_effort` group by `zt_effort`.`date`;
CREATE OR REPLACE VIEW `ztv_daystoryopen` AS select count(*) AS `storyopen`,left(`zt_action`.`date`,10) AS `day` from `zt_action` where ((`zt_action`.`objectType` = 'story') and (`zt_action`.`action` = 'opened')) group by left(`zt_action`.`date`,10);
CREATE OR REPLACE VIEW `ztv_daystoryclose` AS select count(*) AS `storyclose`,left(`zt_action`.`date`,10) AS `day` from `zt_action` where ((`zt_action`.`objectType` = 'story') and (`zt_action`.`action` = 'closed')) group by left(`zt_action`.`date`,10);
CREATE OR REPLACE VIEW `ztv_daytaskopen` AS select count(*) AS `taskopen`,left(`zt_action`.`date`,10) AS `day` from `zt_action` where ((`zt_action`.`objectType` = 'task') and (`zt_action`.`action` = 'opened')) group by left(`zt_action`.`date`,10);
CREATE OR REPLACE VIEW `ztv_daytaskfinish` AS select count(*) AS `taskfinish`,left(`zt_action`.`date`,10) AS `day` from `zt_action` where ((`zt_action`.`objectType` = 'task') and (`zt_action`.`action` = 'finished')) group by left(`zt_action`.`date`,10);
CREATE OR REPLACE VIEW `ztv_daybugopen` AS select count(*) AS `bugopen`,left(`zt_action`.`date`,10) AS `day` from `zt_action` where ((`zt_action`.`objectType` = 'bug') and (`zt_action`.`action` = 'opened')) group by left(`zt_action`.`date`,10);
CREATE OR REPLACE VIEW `ztv_daybugresolve` AS select count(*) AS `bugresolve`,left(`zt_action`.`date`,10) AS `day` from `zt_action` where ((`zt_action`.`objectType` = 'bug') and (`zt_action`.`action` = 'resolved')) group by left(`zt_action`.`date`,10);
CREATE OR REPLACE VIEW `ztv_dayactions` AS select count(*) AS `actions`,left(`zt_action`.`date`,10) AS `day` from `zt_action` group by left(`zt_action`.`date`,10);
CREATE OR REPLACE VIEW `ztv_daystoryopen` AS select COUNT(1) AS `storyopen`,left(`zt_action`.`date`,10) AS `day` from `zt_action` where ((`zt_action`.`objectType` = 'story') and (`zt_action`.`action` = 'opened')) group by left(`zt_action`.`date`,10);
CREATE OR REPLACE VIEW `ztv_daystoryclose` AS select COUNT(1) AS `storyclose`,left(`zt_action`.`date`,10) AS `day` from `zt_action` where ((`zt_action`.`objectType` = 'story') and (`zt_action`.`action` = 'closed')) group by left(`zt_action`.`date`,10);
CREATE OR REPLACE VIEW `ztv_daytaskopen` AS select COUNT(1) AS `taskopen`,left(`zt_action`.`date`,10) AS `day` from `zt_action` where ((`zt_action`.`objectType` = 'task') and (`zt_action`.`action` = 'opened')) group by left(`zt_action`.`date`,10);
CREATE OR REPLACE VIEW `ztv_daytaskfinish` AS select COUNT(1) AS `taskfinish`,left(`zt_action`.`date`,10) AS `day` from `zt_action` where ((`zt_action`.`objectType` = 'task') and (`zt_action`.`action` = 'finished')) group by left(`zt_action`.`date`,10);
CREATE OR REPLACE VIEW `ztv_daybugopen` AS select COUNT(1) AS `bugopen`,left(`zt_action`.`date`,10) AS `day` from `zt_action` where ((`zt_action`.`objectType` = 'bug') and (`zt_action`.`action` = 'opened')) group by left(`zt_action`.`date`,10);
CREATE OR REPLACE VIEW `ztv_daybugresolve` AS select COUNT(1) AS `bugresolve`,left(`zt_action`.`date`,10) AS `day` from `zt_action` where ((`zt_action`.`objectType` = 'bug') and (`zt_action`.`action` = 'resolved')) group by left(`zt_action`.`date`,10);
CREATE OR REPLACE VIEW `ztv_dayactions` AS select COUNT(1) AS `actions`,left(`zt_action`.`date`,10) AS `day` from `zt_action` group by left(`zt_action`.`date`,10);
REPLACE INTO `zt_report` (`code`, `name`, `module`, `sql`, `vars`, `langs`, `params`, `step`, `desc`, `addedBy`, `addedDate`) VALUES
('product-invest', '{\"zh-cn\":\"\\u4ea7\\u54c1\\u6295\\u5165\\u8868\",\"zh-tw\":\"\\u7522\\u54c1\\u6295\\u5165\\u8868\",\"en\":\"Product Investment\"}', ',product', 'select t1.id,t1.name,1 as projects, round(t3.consumed,2) as consumed from TABLE_PRODUCT as t1\r\n left join TABLE_PROJECTPRODUCT as t2 on t1.id=t2.product\r\n left join ztv_projectsummary as t3 on t2.project=t3.project\r\n left join TABLE_PROJECT as t4 on t2.project=t4.id\r\n left join TABLE_PROGRAM as t5 on t1.program=t5.id\r\n where t1.deleted=\'0\' and t4.deleted=\'0\' and t4.type=\'project\'\r\norder by t5.`order` asc, t1.line desc, t1.`order` asc', '', '{\"projects\":{\"zh-cn\":\"\\u9879\\u76ee\\u6570\",\"zh-tw\":\"\\u9879\\u76ee\\u6570\",\"en\":\"Projects\"},\"consumed\":{\"zh-cn\":\"\\u5df2\\u6d88\\u8017\\u5de5\\u65f6\",\"zh-tw\":\"\\u5df2\\u6d88\\u8017\\u5de5\\u65f6\",\"en\":\"Cost(h)\"}}', '{\"group1\":\"name\",\"group2\":\"\",\"reportField\":[\"projects\",\"consumed\"],\"reportType\":[\"sum\",\"sum\"],\"sumAppend\":[\"projects\",\"consumed\"]}', 2, '{\"zh-cn\":\"\\u5217\\u51fa\\u6bcf\\u4e2a\\u4ea7\\u54c1\\u7684\\u9879\\u76ee\\u603b\\u6570\\uff0c\\u5df2\\u7ecf\\u6d88\\u8017\\u7684\\u5de5\\u65f6\\u3002\",\"zh-tw\":\"\\u5217\\u51fa\\u6bcf\\u500b\\u7522\\u54c1\\u7684\\u9805\\u76ee\\u7e3d\\u6578\\uff0c\\u5df2\\u7d93\\u6d88\\u8017\\u7684\\u5de5\\u6642\\u3002\",\"en\":\"Number of projects and consumed hours.\"}', 'admin', '2015-07-20 14:21:30'),
+23 -23
View File
@@ -2694,37 +2694,37 @@ CREATE TABLE IF NOT EXISTS `zt_report` (
CREATE UNIQUE INDEX `code` ON `zt_report`(`code`);
-- DROP VIEW IF EXISTS `ztv_executionsummary`;
CREATE OR REPLACE VIEW `ztv_executionsummary` AS select `zt_task`.`execution` AS `execution`,sum(if((`zt_task`.`parent` >= '0'),`zt_task`.`estimate`,0)) AS `estimate`,sum(if((`zt_task`.`parent` >= '0'),`zt_task`.`consumed`,0)) AS `consumed`,sum(if(((`zt_task`.`status` <> 'cancel') and (`zt_task`.`status` <> 'closed') and (`zt_task`.`parent` >= '0')),`zt_task`.`left`,0)) AS `left`,count(0) AS `number`,sum(if(((`zt_task`.`status` <> 'done') and (`zt_task`.`status` <> 'closed')),1,0)) AS `undone`,sum(if(`zt_task`.`parent` >= '0',`zt_task`.`consumed`,0) + if(`zt_task`.`status` <> 'cancel' and `zt_task`.`status` <> 'closed' and `zt_task`.`parent` >= '0',`zt_task`.`left`,0)) AS `totalReal` from `zt_task` where (`zt_task`.`deleted` = '0') group by `zt_task`.`execution`;
CREATE OR REPLACE VIEW `ztv_executionsummary` AS select `zt_task`.`execution` AS `execution`,sum(if((`zt_task`.`parent` >= '0'),`zt_task`.`estimate`,0)) AS `estimate`,sum(if((`zt_task`.`parent` >= '0'),`zt_task`.`consumed`,0)) AS `consumed`,sum(if(((`zt_task`.`status` <> 'cancel') and (`zt_task`.`status` <> 'closed') and (`zt_task`.`parent` >= '0')),`zt_task`.`left`,0)) AS `left`,COUNT(0) AS `number`,sum(if(((`zt_task`.`status` <> 'done') and (`zt_task`.`status` <> 'closed')),1,0)) AS `undone`,sum(if(`zt_task`.`parent` >= '0',`zt_task`.`consumed`,0) + if(`zt_task`.`status` <> 'cancel' and `zt_task`.`status` <> 'closed' and `zt_task`.`parent` >= '0',`zt_task`.`left`,0)) AS `totalReal` from `zt_task` where (`zt_task`.`deleted` = '0') group by `zt_task`.`execution`;
-- DROP VIEW IF EXISTS `ztv_projectsummary`;
CREATE OR REPLACE VIEW `ztv_projectsummary` AS select `zt_task`.`project` AS `project`,sum(if(`zt_task`.`parent` >= '0',`zt_task`.`estimate`,0)) AS `estimate`,sum(if(`zt_task`.`parent` >= '0',`zt_task`.`consumed`,0)) AS `consumed`,sum(if((`zt_task`.`status` <> 'cancel') and (`zt_task`.`status` <> 'closed') and (`zt_task`.`parent` >= '0'),`zt_task`.`left`,0)) AS `left`,count(0) AS `number`,sum(if(((`zt_task`.`status` <> 'done') and (`zt_task`.`status` <> 'closed')),1,0)) AS `undone`,sum(if(`zt_task`.`parent` >= '0',`zt_task`.`consumed`,0) + if(`zt_task`.`status` <> 'cancel' and `zt_task`.`status` <> 'closed' and `zt_task`.`parent` >= '0',`zt_task`.`left`,0)) AS `totalReal` from `zt_task` where (`zt_task`.`deleted` = '0') group by `zt_task`.`project`;
CREATE OR REPLACE VIEW `ztv_projectsummary` AS select `zt_task`.`project` AS `project`,sum(if(`zt_task`.`parent` >= '0',`zt_task`.`estimate`,0)) AS `estimate`,sum(if(`zt_task`.`parent` >= '0',`zt_task`.`consumed`,0)) AS `consumed`,sum(if((`zt_task`.`status` <> 'cancel') and (`zt_task`.`status` <> 'closed') and (`zt_task`.`parent` >= '0'),`zt_task`.`left`,0)) AS `left`,COUNT(0) AS `number`,sum(if(((`zt_task`.`status` <> 'done') and (`zt_task`.`status` <> 'closed')),1,0)) AS `undone`,sum(if(`zt_task`.`parent` >= '0',`zt_task`.`consumed`,0) + if(`zt_task`.`status` <> 'cancel' and `zt_task`.`status` <> 'closed' and `zt_task`.`parent` >= '0',`zt_task`.`left`,0)) AS `totalReal` from `zt_task` where (`zt_task`.`deleted` = '0') group by `zt_task`.`project`;
-- DROP VIEW IF EXISTS `ztv_projectstories`;
CREATE OR REPLACE VIEW `ztv_projectstories` AS select `t1`.`project` AS `execution`,count('*') AS `stories`,sum(if((`t2`.`status` = 'closed'),0,1)) AS `undone` from ((`zt_projectstory` `t1` left join `zt_story` `t2` on((`t1`.`story` = `t2`.`id`))) left join `zt_project` `t3` on((`t1`.`project` = `t3`.`id`))) where ((`t2`.`deleted` = '0') and (`t3`.`type` in ('sprint','stage'))) group by `t1`.`project`;
CREATE OR REPLACE VIEW `ztv_projectstories` AS select `t1`.`project` AS `execution`,COUNT(1) AS `stories`,sum(if((`t2`.`status` = 'closed'),0,1)) AS `undone` from ((`zt_projectstory` `t1` left join `zt_story` `t2` on((`t1`.`story` = `t2`.`id`))) left join `zt_project` `t3` on((`t1`.`project` = `t3`.`id`))) where ((`t2`.`deleted` = '0') and (`t3`.`type` in ('sprint','stage'))) group by `t1`.`project`;
-- DROP VIEW IF EXISTS `ztv_projectteams`;
CREATE OR REPLACE VIEW `ztv_projectteams` AS select `zt_team`.`root` AS `execution`,count('*') AS `teams` from `zt_team` where (`zt_team`.`type` = 'execution') group by `zt_team`.`root`;
CREATE OR REPLACE VIEW `ztv_projectteams` AS select `zt_team`.`root` AS `execution`,COUNT(1) AS `teams` from `zt_team` where (`zt_team`.`type` = 'execution') group by `zt_team`.`root`;
-- DROP VIEW IF EXISTS `ztv_projectbugs`;
CREATE OR REPLACE VIEW `ztv_projectbugs` AS select `zt_bug`.`execution` AS `execution`,count(0) AS `bugs`,sum(if((`zt_bug`.`resolution` = ''),0,1)) AS `resolutions`,sum(if((`zt_bug`.`severity` <= 2),1,0)) AS `seriousBugs` from `zt_bug` where (`zt_bug`.`deleted` = '0') group by `zt_bug`.`execution`;
CREATE OR REPLACE VIEW `ztv_projectbugs` AS select `zt_bug`.`execution` AS `execution`,COUNT(1) AS `bugs`,sum(if((`zt_bug`.`resolution` = ''),0,1)) AS `resolutions`,sum(if((`zt_bug`.`severity` <= 2),1,0)) AS `seriousBugs` from `zt_bug` where (`zt_bug`.`deleted` = '0') group by `zt_bug`.`execution`;
-- DROP VIEW IF EXISTS `ztv_productbugs`;
CREATE OR REPLACE VIEW `ztv_productbugs` AS select `zt_bug`.`product` AS `product`,count(0) AS `bugs`,sum(if((`zt_bug`.`resolution` = ''),0,1)) AS `resolutions`,sum(if((`zt_bug`.`severity` <= 2),1,0)) AS `seriousBugs` from `zt_bug` where (`zt_bug`.`deleted` = '0') group by `zt_bug`.`product`;
CREATE OR REPLACE VIEW `ztv_productbugs` AS select `zt_bug`.`product` AS `product`,COUNT(1) AS `bugs`,sum(if((`zt_bug`.`resolution` = ''),0,1)) AS `resolutions`,sum(if((`zt_bug`.`severity` <= 2),1,0)) AS `seriousBugs` from `zt_bug` where (`zt_bug`.`deleted` = '0') group by `zt_bug`.`product`;
-- DROP VIEW IF EXISTS `ztv_productstories`;
CREATE OR REPLACE VIEW `ztv_productstories` AS select `zt_story`.`product` AS `product`,count('*') AS `stories`,sum(if((`zt_story`.`status` = 'closed'),0,1)) AS `undone` from `zt_story` where (`zt_story`.`deleted` = '0') group by `zt_story`.`product`;
CREATE OR REPLACE VIEW `ztv_productstories` AS select `zt_story`.`product` AS `product`,COUNT(1) AS `stories`,sum(if((`zt_story`.`status` = 'closed'),0,1)) AS `undone` from `zt_story` where (`zt_story`.`deleted` = '0') group by `zt_story`.`product`;
-- DROP VIEW IF EXISTS `ztv_dayuserlogin`;
CREATE OR REPLACE VIEW `ztv_dayuserlogin` AS select count(*) AS `userlogin`,left(`zt_action`.`date`,10) AS `day` from `zt_action` where ((`zt_action`.`objectType` = 'user') and (`zt_action`.`action` = 'login')) group by left(`zt_action`.`date`,10);
CREATE OR REPLACE VIEW `ztv_dayuserlogin` AS select COUNT(1) AS `userlogin`,left(`zt_action`.`date`,10) AS `day` from `zt_action` where ((`zt_action`.`objectType` = 'user') and (`zt_action`.`action` = 'login')) group by left(`zt_action`.`date`,10);
-- DROP VIEW IF EXISTS `ztv_dayeffort`;
CREATE OR REPLACE VIEW `ztv_dayeffort` AS select round(sum(`zt_effort`.`consumed`),1) AS `consumed`,`zt_effort`.`date` AS `date` from `zt_effort` group by `zt_effort`.`date`;
-- DROP VIEW IF EXISTS `ztv_daystoryopen`;
CREATE OR REPLACE VIEW `ztv_daystoryopen` AS select count(*) AS `storyopen`,left(`zt_action`.`date`,10) AS `day` from `zt_action` where ((`zt_action`.`objectType` = 'story') and (`zt_action`.`action` = 'opened')) group by left(`zt_action`.`date`,10);
CREATE OR REPLACE VIEW `ztv_daystoryopen` AS select COUNT(1) AS `storyopen`,left(`zt_action`.`date`,10) AS `day` from `zt_action` where ((`zt_action`.`objectType` = 'story') and (`zt_action`.`action` = 'opened')) group by left(`zt_action`.`date`,10);
-- DROP VIEW IF EXISTS `ztv_daystoryclose`;
CREATE OR REPLACE VIEW `ztv_daystoryclose` AS select count(*) AS `storyclose`,left(`zt_action`.`date`,10) AS `day` from `zt_action` where ((`zt_action`.`objectType` = 'story') and (`zt_action`.`action` = 'closed')) group by left(`zt_action`.`date`,10);
CREATE OR REPLACE VIEW `ztv_daystoryclose` AS select COUNT(1) AS `storyclose`,left(`zt_action`.`date`,10) AS `day` from `zt_action` where ((`zt_action`.`objectType` = 'story') and (`zt_action`.`action` = 'closed')) group by left(`zt_action`.`date`,10);
-- DROP VIEW IF EXISTS `ztv_daytaskopen`;
CREATE OR REPLACE VIEW `ztv_daytaskopen` AS select count(*) AS `taskopen`,left(`zt_action`.`date`,10) AS `day` from `zt_action` where ((`zt_action`.`objectType` = 'task') and (`zt_action`.`action` = 'opened')) group by left(`zt_action`.`date`,10);
CREATE OR REPLACE VIEW `ztv_daytaskopen` AS select COUNT(1) AS `taskopen`,left(`zt_action`.`date`,10) AS `day` from `zt_action` where ((`zt_action`.`objectType` = 'task') and (`zt_action`.`action` = 'opened')) group by left(`zt_action`.`date`,10);
-- DROP VIEW IF EXISTS `ztv_daytaskfinish`;
CREATE OR REPLACE VIEW `ztv_daytaskfinish` AS select count(*) AS `taskfinish`,left(`zt_action`.`date`,10) AS `day` from `zt_action` where ((`zt_action`.`objectType` = 'task') and (`zt_action`.`action` = 'finished')) group by left(`zt_action`.`date`,10);
CREATE OR REPLACE VIEW `ztv_daytaskfinish` AS select COUNT(1) AS `taskfinish`,left(`zt_action`.`date`,10) AS `day` from `zt_action` where ((`zt_action`.`objectType` = 'task') and (`zt_action`.`action` = 'finished')) group by left(`zt_action`.`date`,10);
-- DROP VIEW IF EXISTS `ztv_daybugopen`;
CREATE OR REPLACE VIEW `ztv_daybugopen` AS select count(*) AS `bugopen`,left(`zt_action`.`date`,10) AS `day` from `zt_action` where ((`zt_action`.`objectType` = 'bug') and (`zt_action`.`action` = 'opened')) group by left(`zt_action`.`date`,10);
CREATE OR REPLACE VIEW `ztv_daybugopen` AS select COUNT(1) AS `bugopen`,left(`zt_action`.`date`,10) AS `day` from `zt_action` where ((`zt_action`.`objectType` = 'bug') and (`zt_action`.`action` = 'opened')) group by left(`zt_action`.`date`,10);
-- DROP VIEW IF EXISTS `ztv_daybugresolve`;
CREATE OR REPLACE VIEW `ztv_daybugresolve` AS select count(*) AS `bugresolve`,left(`zt_action`.`date`,10) AS `day` from `zt_action` where ((`zt_action`.`objectType` = 'bug') and (`zt_action`.`action` = 'resolved')) group by left(`zt_action`.`date`,10);
CREATE OR REPLACE VIEW `ztv_daybugresolve` AS select COUNT(1) AS `bugresolve`,left(`zt_action`.`date`,10) AS `day` from `zt_action` where ((`zt_action`.`objectType` = 'bug') and (`zt_action`.`action` = 'resolved')) group by left(`zt_action`.`date`,10);
-- DROP VIEW IF EXISTS `ztv_dayactions`;
CREATE OR REPLACE VIEW `ztv_dayactions` AS select count(*) AS `actions`,left(`zt_action`.`date`,10) AS `day` from `zt_action` group by left(`zt_action`.`date`,10);
CREATE OR REPLACE VIEW `ztv_dayactions` AS select COUNT(1) AS `actions`,left(`zt_action`.`date`,10) AS `day` from `zt_action` group by left(`zt_action`.`date`,10);
-- DROP VIEW IF EXISTS `ztv_normalproduct`;
CREATE OR REPLACE VIEW `ztv_normalproduct` AS SELECT * FROM `zt_product` WHERE `shadow` = 0;
@@ -15750,8 +15750,8 @@ CREATE FUNCTION qc_cminited($project int, $category varchar(30)) returns int REA
begin
declare products int default 0__DELIMITER__
declare objects int default 0__DELIMITER__
select count(*) from zt_projectproduct where project = $project into products__DELIMITER__
select count(distinct product) from zt_object where project = $project and category = $category and type = 'taged' and product in (select product from zt_projectproduct where project = $project) into objects__DELIMITER__
select COUNT(1) from zt_projectproduct where project = $project into products__DELIMITER__
select COUNT(DISTINCT product) from zt_object where project = $project and category = $category and type = 'taged' and product in (select product from zt_projectproduct where project = $project) into objects__DELIMITER__
IF products = objects THEN
return 1__DELIMITER__
ELSEIF products != objects THEN
@@ -15828,9 +15828,9 @@ DROP FUNCTION IF EXISTS `qc_pgmallrequirementstage`;
CREATE FUNCTION `qc_pgmallrequirementstage`($project int) RETURNS int(1) READS SQL DATA
BEGIN
-- 获取项目产品总数
select count(*) as products from zt_projectproduct where project = $project into @totalproduct__DELIMITER__
select COUNT(1) AS products from zt_projectproduct where project = $project into @totalproduct__DELIMITER__
-- 获取已经设置需求阶段的产品总数
select count(*) as product from (select product from zt_projectproduct where project in (select id from zt_project where project = $project and type = 'stage' and attribute = 'request' and deleted = '0') GROUP BY product) as product into @product__DELIMITER__
select COUNT(1) AS product from (select product from zt_projectproduct where project in (select id from zt_project where project = $project and type = 'stage' and attribute = 'request' and deleted = '0') GROUP BY product) as product into @product__DELIMITER__
-- 让项目产品总数和已设置需求阶段产品总数比较,都设置返回1,否则返回0
if @totalproduct = @product then return 1__DELIMITER__
end if__DELIMITER__
@@ -15883,9 +15883,9 @@ DROP FUNCTION IF EXISTS `qc_pgmspecifiedtypeactualdays`;
CREATE FUNCTION `qc_pgmspecifiedtypeactualdays`($project int,$attribute varchar(50)) RETURNS int(11) READS SQL DATA
BEGIN
-- 查询某类型的阶段总数
select count(*) from zt_project where project = $project and attribute = $attribute and deleted = '0' and id not in (select parent from zt_project where project = $project and attribute = $attribute and grade = 2 group by parent) into @totalstory__DELIMITER__
select COUNT(1) from zt_project where project = $project and attribute = $attribute and deleted = '0' and id not in (select parent from zt_project where project = $project and attribute = $attribute and grade = 2 group by parent) into @totalstory__DELIMITER__
-- 查询某类型已设置实际工期的阶段总数
select count(*) from zt_project where project = $project and attribute = $attribute and deleted = '0' and realDuration > 0 and id not in (select parent from zt_project where project = $project and attribute = $attribute and grade = 2 group by parent) into @setstory__DELIMITER__
select COUNT(1) from zt_project where project = $project and attribute = $attribute and deleted = '0' and realDuration > 0 and id not in (select parent from zt_project where project = $project and attribute = $attribute and grade = 2 group by parent) into @setstory__DELIMITER__
-- 查询项目下某类型阶段实际工期总数
select sum(realDuration) as realDuration from zt_project where project = $project and attribute = $attribute and deleted = '0' and realDuration > 0 and id not in (select parent from zt_project where project = $project and attribute = $attribute and grade = 2 group by parent) into @days__DELIMITER__
-- 判断项目下某类型的阶段是否都已设置实际工期
@@ -15906,9 +15906,9 @@ DROP FUNCTION IF EXISTS `qc_pgmstageactualduration`;
CREATE FUNCTION `qc_pgmstageactualduration`($product int, $attribute varchar(50)) RETURNS int(11) READS SQL DATA
BEGIN
-- 查找某类型的阶段总数
select count(*) as totalduration from zt_project where id in (select project from zt_projectproduct where product = $product) and type = 'stage' and attribute = $attribute and deleted = '0' and id not in (select parent from zt_project where id in (select project from zt_projectproduct where product = $product) and attribute = $attribute and grade = 2 group by parent) into @totalduration__DELIMITER__
select COUNT(1) AS totalduration from zt_project where id in (select project from zt_projectproduct where product = $product) and type = 'stage' and attribute = $attribute and deleted = '0' and id not in (select parent from zt_project where id in (select project from zt_projectproduct where product = $product) and attribute = $attribute and grade = 2 group by parent) into @totalduration__DELIMITER__
-- 查某类型阶段已设置实际工期的总数
select count(*) as setduration from zt_project where id in (select project from zt_projectproduct where product = $product) and type = 'stage' and attribute = $attribute and deleted = '0' and id not in (select parent from zt_project where id in (select project from zt_projectproduct where product = $product) and attribute = $attribute and grade = 2 group by parent) and realDuration > 0 into @setduration__DELIMITER__
select COUNT(1) AS setduration from zt_project where id in (select project from zt_projectproduct where product = $product) and type = 'stage' and attribute = $attribute and deleted = '0' and id not in (select parent from zt_project where id in (select project from zt_projectproduct where product = $product) and attribute = $attribute and grade = 2 group by parent) and realDuration > 0 into @setduration__DELIMITER__
-- 指定产品下某类型的阶段实际工期总和
select sum(realDuration) as duration from zt_project where id in (select project from zt_projectproduct where product = $product) and type = 'stage' and attribute = $attribute and deleted = '0' and id not in (select parent from zt_project where id in (select project from zt_projectproduct where product = $product) and attribute = $attribute and grade = 2 group by parent) and realDuration > 0 into @duration__DELIMITER__
-- 需要判断该类型阶段都已设置实际工期,否则不统计
+1 -1
View File
@@ -728,7 +728,7 @@ class control extends baseControl
if(!empty($_POST[$field->field]))
{
$sqlClass = new sql();
$sql = "SELECT COUNT(*) AS count FROM $flow->table WHERE `$field->field` = " . $sqlClass->quote(fixer::input('post')->get($field->field));
$sql = "SELECT COUNT(1) AS count FROM $flow->table WHERE `$field->field` = " . $sqlClass->quote(fixer::input('post')->get($field->field));
if(isset($_POST['id'])) $sql .= ' AND `id` != ' . (int)$_POST['id'];
$row = $this->dbh->query($sql)->fetch();
+1 -1
View File
@@ -1327,7 +1327,7 @@ class baseDAO
if($funcName == 'unique')
{
$args = func_get_args();
$sql = "SELECT COUNT(*) AS `count` FROM $this->table WHERE `$fieldName` = " . $this->sqlobj->quote($value);
$sql = "SELECT COUNT(1) AS `count` FROM $this->table WHERE `$fieldName` = " . $this->sqlobj->quote($value);
if($condition) $sql .= ' AND ' . $condition;
try
{
+2 -2
View File
@@ -1492,7 +1492,7 @@ class actionModel extends model
/* 移除搜索中的时间筛选条件。 */
/* Remove time filter from search. */
$condition = preg_replace("/AND +date[\<\>]'\d{4}\-\d{2}\-\d{2}'/", '', $condition);
$count = $this->dao->select('count(*) as count')
$count = $this->dao->select('COUNT(1) AS count')
->from(TABLE_ACTION)
->where($condition)
->andWhere('date' . ($direction == 'next' ? '<' : '>') . "'{$date}'")
@@ -1942,7 +1942,7 @@ class actionModel extends model
if($action->objectType == 'execution')
{
if($object->deleted && empty($object->project)) return $this->lang->action->undeletedTips;
$projectCount = $this->dao->select('count(*) AS count')->from(TABLE_PROJECT)->where('id')->eq($object->project)->andWhere('deleted')->eq('0')->fetch('count');
$projectCount = $this->dao->select('COUNT(1) AS count')->from(TABLE_PROJECT)->where('id')->eq($object->project)->andWhere('deleted')->eq('0')->fetch('count');
if((int)$projectCount == 0) return $this->lang->action->executionNoProject;
}
elseif($action->objectType == 'repo' && in_array($object->SCM, array('Gitlab', 'Gitea', 'Gogs')))
+2 -2
View File
@@ -89,11 +89,11 @@ $tester->app->upgrading = true;
$version = $tester->dao->select('value')->from(TABLE_CONFIG)->where('`key`')->eq('version')->andWhere('owner')->eq('system')->andWhere('module')->eq('common')->fetch('value');
$action->createTest($objectTypeList[0], $objectIDList[0], $storyActionTypeList[0], $comment[0], '', '', '', $versionList[0]);
r($tester->dao->select('count(*) as count')->from('zt_actionrecent')->fetch('count')) && p() && e('8'); //测试升级中的并且版本号小于18.7的情况,不创建actionrecent
r($tester->dao->select('COUNT(1) AS count')->from('zt_actionrecent')->fetch('count')) && p() && e('8'); //测试升级中的并且版本号小于18.7的情况,不创建actionrecent
unset(dao::$cache['zt_actionrecent']);
$action->createTest($objectTypeList[0], $objectIDList[0], $storyActionTypeList[0], $comment[0], '', '', '', $versionList[1]);
r($tester->dao->select('count(*) as count')->from('zt_actionrecent')->fetch('count')) && p() && e('9'); //测试升级中的并且版本号大于18.7的情况,创建actionrecent
r($tester->dao->select('COUNT(1) AS count')->from('zt_actionrecent')->fetch('count')) && p() && e('9'); //测试升级中的并且版本号大于18.7的情况,创建actionrecent
$tester->dao->update(TABLE_CONFIG)->set('value')->eq($version)->where('`key`')->eq('version')->andWhere('owner')->eq('system')->andWhere('module')->eq('common')->exec();
$tester->app->upgrading = false;
+1 -1
View File
@@ -966,7 +966,7 @@ class aiModel extends model
*/
public function countLatestMiniPrograms()
{
return (int)$this->dao->select('COUNT(*) as count')
return (int)$this->dao->select('COUNT(1) AS count')
->from(TABLE_AI_MINIPROGRAM)
->where('deleted')->eq('0')
->andWhere('published')->eq('1')
+1 -1
View File
@@ -59,7 +59,7 @@ class aiappModel extends model
*/
private function countLatestMiniPrograms()
{
return (int)$this->dao->select('COUNT(*) as count')
return (int)$this->dao->select('COUNT(1) AS count')
->from(TABLE_AI_MINIPROGRAM)
->where('deleted')->eq('0')
->andWhere('published')->eq('1')
+2 -2
View File
@@ -1421,7 +1421,7 @@ class blockZen extends block
$productIdList = array_keys($products);
if(!empty($productIdList))
{
$fields = 'product, count(*) as total';
$fields = 'product, COUNT(1) AS total';
$stories = $this->dao->select($fields)->from(TABLE_STORY)->where('product')->in($productIdList)->andWhere('deleted')->eq('0')->groupBy('product')->fetchPairs();
$bugs = $this->dao->select($fields)->from(TABLE_BUG)->where('product')->in($productIdList)->andWhere('deleted')->eq('0')->groupBy('product')->fetchPairs();
$releases = $this->dao->select($fields)->from(TABLE_RELEASE)->where('product')->in($productIdList)->andWhere('deleted')->eq('0')->groupBy('product')->fetchPairs();
@@ -1949,7 +1949,7 @@ class blockZen extends block
*/
protected function printQaOverviewBlock(object $block): void
{
$casePairs = $this->dao->select('lastRunResult, COUNT(*) AS count')->from(TABLE_CASE)
$casePairs = $this->dao->select('lastRunResult, COUNT(1) AS count')->from(TABLE_CASE)
->where('1=1')
->beginIF($block->module != 'my' && $this->session->project)->andWhere('project')->eq((int)$this->session->project)->fi()
->groupBy('lastRunResult')
+14 -14
View File
@@ -1221,7 +1221,7 @@ class bugModel extends model
public function getStoryBugCounts(array $stories, int $executionID = 0): array
{
if(empty($stories)) return array();
$bugCounts = $this->dao->select('story, COUNT(*) AS bugs')
$bugCounts = $this->dao->select('story, COUNT(1) AS bugs')
->from(TABLE_BUG)
->where('story')->in($stories)
->andWhere('deleted')->eq(0)
@@ -1408,7 +1408,7 @@ class bugModel extends model
*/
public function getDataOfOpenedBugsPerDay(): array
{
return $this->dao->select('DATE_FORMAT(openedDate, "%Y-%m-%d") AS name, COUNT(*) AS value')->from(TABLE_BUG)->where($this->reportCondition())->groupBy('name')->orderBy('name')->fetchAll();
return $this->dao->select('DATE_FORMAT(openedDate, "%Y-%m-%d") AS name, COUNT(1) AS value')->from(TABLE_BUG)->where($this->reportCondition())->groupBy('name')->orderBy('name')->fetchAll();
}
/**
@@ -1420,7 +1420,7 @@ class bugModel extends model
*/
public function getDataOfResolvedBugsPerDay(): array
{
return $this->dao->select('DATE_FORMAT(resolvedDate, "%Y-%m-%d") AS name, COUNT(*) AS value')->from(TABLE_BUG)
return $this->dao->select('DATE_FORMAT(resolvedDate, "%Y-%m-%d") AS name, COUNT(1) AS value')->from(TABLE_BUG)
->where($this->reportCondition())
->groupBy('name')
->having('name != 0000-00-00')
@@ -1437,7 +1437,7 @@ class bugModel extends model
*/
public function getDataOfClosedBugsPerDay(): array
{
return $this->dao->select('DATE_FORMAT(closedDate, "%Y-%m-%d") AS name, COUNT(*) AS value')->from(TABLE_BUG)
return $this->dao->select('DATE_FORMAT(closedDate, "%Y-%m-%d") AS name, COUNT(1) AS value')->from(TABLE_BUG)
->where($this->reportCondition())
->groupBy('name')
->having('name != 0000-00-00')
@@ -1454,7 +1454,7 @@ class bugModel extends model
*/
public function getDataOfOpenedBugsPerUser(): array
{
$datas = $this->dao->select('openedBy AS name, COUNT(*) AS value')->from(TABLE_BUG)->where($this->reportCondition())->groupBy('name')->orderBy('value DESC')->fetchAll('name');
$datas = $this->dao->select('openedBy AS name, COUNT(1) AS value')->from(TABLE_BUG)->where($this->reportCondition())->groupBy('name')->orderBy('value DESC')->fetchAll('name');
if(!$datas) return array();
if(!isset($this->users)) $this->users = $this->loadModel('user')->getPairs('noletter');
@@ -1472,7 +1472,7 @@ class bugModel extends model
*/
public function getDataOfResolvedBugsPerUser(): array
{
$datas = $this->dao->select('resolvedBy AS name, COUNT(*) AS value')
$datas = $this->dao->select('resolvedBy AS name, COUNT(1) AS value')
->from(TABLE_BUG)->where($this->reportCondition())
->andWhere('resolvedBy')->ne('')
->groupBy('name')
@@ -1495,7 +1495,7 @@ class bugModel extends model
*/
public function getDataOfClosedBugsPerUser(): array
{
$datas = $this->dao->select('closedBy AS name, COUNT(*) AS value')
$datas = $this->dao->select('closedBy AS name, COUNT(1) AS value')
->from(TABLE_BUG)
->where($this->reportCondition())
->andWhere('closedBy')->ne('')
@@ -1519,7 +1519,7 @@ class bugModel extends model
*/
public function getDataOfBugsPerSeverity(): array
{
$datas = $this->dao->select('severity AS name, COUNT(*) AS value')->from(TABLE_BUG)->where($this->reportCondition())->groupBy('name')->orderBy('value DESC')->fetchAll('name');
$datas = $this->dao->select('severity AS name, COUNT(1) AS value')->from(TABLE_BUG)->where($this->reportCondition())->groupBy('name')->orderBy('value DESC')->fetchAll('name');
if(!$datas) return array();
foreach($datas as $severity => $data) $data->name = $this->lang->bug->report->bugsPerSeverity->graph->xAxisName . ':' . zget($this->lang->bug->severityList, $severity);
@@ -1535,7 +1535,7 @@ class bugModel extends model
*/
public function getDataOfBugsPerResolution(): array
{
$datas = $this->dao->select('resolution AS name, COUNT(*) AS value')
$datas = $this->dao->select('resolution AS name, COUNT(1) AS value')
->from(TABLE_BUG)
->where($this->reportCondition())
->andWhere('resolution')->ne('')
@@ -1558,7 +1558,7 @@ class bugModel extends model
*/
public function getDataOfBugsPerStatus(): array
{
$datas = $this->dao->select('status AS name, COUNT(*) AS value')->from(TABLE_BUG)->where($this->reportCondition())->groupBy('name')->orderBy('value DESC')->fetchAll('name');
$datas = $this->dao->select('status AS name, COUNT(1) AS value')->from(TABLE_BUG)->where($this->reportCondition())->groupBy('name')->orderBy('value DESC')->fetchAll('name');
if(!$datas) return array();
foreach($datas as $status => $data) $data->name = zget($this->lang->bug->statusList, $status);
@@ -1575,7 +1575,7 @@ class bugModel extends model
*/
public function getDataOfBugsPerPri(): array
{
$datas = $this->dao->select('pri AS name, COUNT(*) AS value')->from(TABLE_BUG)->where($this->reportCondition())->groupBy('name')->orderBy('value DESC')->fetchAll('name');
$datas = $this->dao->select('pri AS name, COUNT(1) AS value')->from(TABLE_BUG)->where($this->reportCondition())->groupBy('name')->orderBy('value DESC')->fetchAll('name');
if(!$datas) return array();
foreach($datas as $data) $data->name = $this->lang->bug->report->bugsPerPri->graph->xAxisName . ':' . zget($this->lang->bug->priList, $data->name);
@@ -1592,7 +1592,7 @@ class bugModel extends model
*/
public function getDataOfBugsPerActivatedCount(): array
{
$datas = $this->dao->select('activatedCount AS name, COUNT(*) AS value')->from(TABLE_BUG)->where($this->reportCondition())->groupBy('name')->orderBy('value DESC')->fetchAll('name');
$datas = $this->dao->select('activatedCount AS name, COUNT(1) AS value')->from(TABLE_BUG)->where($this->reportCondition())->groupBy('name')->orderBy('value DESC')->fetchAll('name');
if(!$datas) return array();
foreach($datas as $data) $data->name = $this->lang->bug->report->bugsPerActivatedCount->graph->xAxisName . ':' . $data->name;
@@ -1609,7 +1609,7 @@ class bugModel extends model
*/
public function getDataOfBugsPerType(): array
{
$datas = $this->dao->select('type AS name, COUNT(*) AS value')->from(TABLE_BUG)->where($this->reportCondition())->groupBy('name')->orderBy('value DESC')->fetchAll('name');
$datas = $this->dao->select('type AS name, COUNT(1) AS value')->from(TABLE_BUG)->where($this->reportCondition())->groupBy('name')->orderBy('value DESC')->fetchAll('name');
if(!$datas) return array();
foreach($datas as $type => $data) $data->name = zget($this->lang->bug->typeList, $type);
@@ -1626,7 +1626,7 @@ class bugModel extends model
*/
public function getDataOfBugsPerAssignedTo(): array
{
$datas = $this->dao->select('assignedTo AS name, COUNT(*) AS value')->from(TABLE_BUG)->where($this->reportCondition())->groupBy('name')->orderBy('value DESC')->fetchAll('name');
$datas = $this->dao->select('assignedTo AS name, COUNT(1) AS value')->from(TABLE_BUG)->where($this->reportCondition())->groupBy('name')->orderBy('value DESC')->fetchAll('name');
if(!$datas) return array();
if(!isset($this->users)) $this->users = $this->loadModel('user')->getPairs('noletter');
@@ -38,7 +38,7 @@ $_POST = array(
$caselib->createFromImportTest(201);
unset($_POST);
$total = $tester->dao->select('count(*) total')->from(TABLE_CASE)->where( 'lib')->eq(201)->fetch('total');
$total = $tester->dao->select('COUNT(1) AS total')->from(TABLE_CASE)->where( 'lib')->eq(201)->fetch('total');
$cases = $tester->dao->select('*')->from(TABLE_CASE)->where( 'lib')->eq(201)->fetchAll('id');
r($total) && p() && e('2'); //添加两条数据之后查询数据条数是否正确
+4 -4
View File
@@ -1862,7 +1862,7 @@ class docModel extends model
{
$today = date('Y-m-d');
$statistic = new stdclass();
$statistic->totalDocs = $this->dao->select('count(*) as count')->from(TABLE_DOC)
$statistic->totalDocs = $this->dao->select('COUNT(1) AS count')->from(TABLE_DOC)
->where('deleted')->eq('0')
->andWhere('type')->in($this->config->doc->docTypes)
->andWhere('vision')->eq($this->config->vision)
@@ -1890,7 +1890,7 @@ class docModel extends model
->andWhere('t2.type')->in($this->config->doc->docTypes)
->fetch('count');
$myStatistic = $this->dao->select("count(*) as myDocs, SUM(views) as docViews, SUM(collects) as docCollects")->from(TABLE_DOC)
$myStatistic = $this->dao->select("COUNT(1) AS myDocs, SUM(views) as docViews, SUM(collects) as docCollects")->from(TABLE_DOC)
->where('addedBy')->eq($this->app->user->account)
->andWhere('type')->in($this->config->doc->docTypes)
->andWhere('deleted')->eq(0)
@@ -2513,7 +2513,7 @@ class docModel extends model
if($action == 'view' && $docStatus == 'normal') $this->dao->update(TABLE_DOC)->set('views = views + 1')->where('id')->eq($docID)->exec();
if($action == 'collect')
{
$collectCount = $this->dao->select('count(*) as count')->from(TABLE_DOCACTION)->where('doc')->eq($docID)->andWhere('action')->eq('collect')->fetch('count');
$collectCount = $this->dao->select('COUNT(1) AS count')->from(TABLE_DOCACTION)->where('doc')->eq($docID)->andWhere('action')->eq('collect')->fetch('count');
$this->dao->update(TABLE_DOC)->set('collects')->eq($collectCount)->where('id')->eq($docID)->exec();
}
@@ -2552,7 +2552,7 @@ class docModel extends model
$this->dao->delete()->from(TABLE_DOCACTION)->where('id')->eq($actionID)->exec();
if($action->action == 'collect')
{
$collectCount = $this->dao->select('count(*) as count')->from(TABLE_DOCACTION)->where('doc')->eq($action->doc)->andWhere('action')->eq('collect')->fetch('count');
$collectCount = $this->dao->select('COUNT(1) AS count')->from(TABLE_DOCACTION)->where('doc')->eq($action->doc)->andWhere('action')->eq('collect')->fetch('count');
$this->dao->update(TABLE_DOC)->set('collects')->eq($collectCount)->where('id')->eq($action->doc)->exec();
}
return !dao::isError();
+1 -1
View File
@@ -3181,7 +3181,7 @@ class executionModel extends model
->limit('11')
->fetchPairs();
$countPairs = $this->dao->select('root, COUNT(*) as count')->from(TABLE_TEAM)
$countPairs = $this->dao->select('root, COUNT(1) AS count')->from(TABLE_TEAM)
->where('( type')->eq('project')
->andWhere('root')->eq($projectID)
->markRight(1)
+2 -2
View File
@@ -373,13 +373,13 @@ class fileTest
public function autoDeleteTest(string $uid): int
{
$this->objectModel->autoDelete($uid);
return $this->objectModel->dao->select('count(*) AS count')->from(TABLE_FILE)->fetch('count');
return $this->objectModel->dao->select('COUNT(1) AS count')->from(TABLE_FILE)->fetch('count');
}
public function processFile4ObjectTest(string $objectType, object $oldObject, object $newObject): array
{
$this->objectModel->processFile4Object($objectType, $oldObject, $newObject);
$count = $this->objectModel->dao->select('count(*) AS count')->from(TABLE_FILE)->fetch('count');
$count = $this->objectModel->dao->select('COUNT(1) AS count')->from(TABLE_FILE)->fetch('count');
return array('old' => $oldObject, 'new' => $newObject, 'count' => $count);
}
+2 -2
View File
@@ -157,7 +157,7 @@ class instanceModel extends model
{
$defaultSpace = $this->loadModel('space')->defaultSpace($this->app->user->account);
$count = $this->dao->select('count(*) as qty')->from(TABLE_INSTANCE)->alias('instance')
$count = $this->dao->select('COUNT(1) AS qty')->from(TABLE_INSTANCE)->alias('instance')
->leftJoin(TABLE_SPACE)->alias('space')->on('space.id=instance.space')
->where('instance.deleted')->eq(0)
->andWhere('space.id')->eq($defaultSpace->id)
@@ -177,7 +177,7 @@ class instanceModel extends model
{
/* REPLACE(domain, .$sysDomain, '') used for special case: new domain is a.com and old domain is b.a.com, domain of instance is c.b.a.com, */
$sysDomain = $this->loadModel('cne')->sysDomain();
$result = $this->dao->select('count(*) as qty')->from(TABLE_INSTANCE)
$result = $this->dao->select('COUNT(1) AS qty')->from(TABLE_INSTANCE)
->where('deleted')->eq(0)
->andWhere("REPLACE(domain, '.$sysDomain', '')")->like("%.%")
->fetch();
+1 -1
View File
@@ -3436,7 +3436,7 @@ class kanbanModel extends model
$kanbanIDList = array();
foreach($spaceList as $kanbanList) $kanbanIDList = array_merge_recursive($kanbanIDList, array_keys($kanbanList));
$cardsCount = $this->dao->select('kanban, COUNT(*) as count')->from(TABLE_KANBANCARD)
$cardsCount = $this->dao->select('kanban, COUNT(1) AS count')->from(TABLE_KANBANCARD)
->where('deleted')->eq(0)
->andWhere('kanban')->in($kanbanIDList)
->groupBy('kanban')
+1 -1
View File
@@ -185,7 +185,7 @@ class kanbanTao extends kanbanModel
*/
protected function updateColumnParent(object $column)
{
$children = $this->dao->select('count(*) as count')->from(TABLE_KANBANCOLUMN)
$children = $this->dao->select('COUNT(1) AS count')->from(TABLE_KANBANCOLUMN)
->where('parent')->eq($column->parent)
->andWhere('id')->ne($column->id)
->andWhere('deleted')->eq('0')
@@ -24,9 +24,9 @@ class count_of_application extends baseCalc
public function getStatement()
{
$count = (int)$this->dao->select('count(*) as count')->from(TABLE_INSTANCE)->where('deleted')->eq(0)->fetch('count');
$count = (int)$this->dao->select('COUNT(1) AS count')->from(TABLE_INSTANCE)->where('deleted')->eq(0)->fetch('count');
return $this->dao->select("count(*) as count, {$count} as instanceCount")->from(TABLE_PIPELINE)
return $this->dao->select("COUNT(1) AS count, {$count} as instanceCount")->from(TABLE_PIPELINE)
->where('deleted')->eq(0);
}
+11 -11
View File
@@ -97,8 +97,8 @@ class myModel extends model
$summaryStories[$productID] = $summaryStory;
}
$plans = $this->dao->select('product, count(*) AS count')->from(TABLE_PRODUCTPLAN)->where('deleted')->eq(0)->andWhere('product')->in($productKeys)->andWhere('end')->gt(helper::now())->groupBy('product')->fetchPairs();
$releases = $this->dao->select('product, count(*) AS count')->from(TABLE_RELEASE)->where('deleted')->eq(0)->andWhere('product')->in($productKeys)->groupBy('product')->fetchPairs();
$plans = $this->dao->select('product, COUNT(1) AS count')->from(TABLE_PRODUCTPLAN)->where('deleted')->eq(0)->andWhere('product')->in($productKeys)->andWhere('end')->gt(helper::now())->groupBy('product')->fetchPairs();
$releases = $this->dao->select('product, COUNT(1) AS count')->from(TABLE_RELEASE)->where('deleted')->eq(0)->andWhere('product')->in($productKeys)->groupBy('product')->fetchPairs();
$executions = $this->dao->select('t1.product,t2.id,t2.name')->from(TABLE_PROJECTPRODUCT)->alias('t1')
->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project=t2.id')
->where('t1.product')->in($productKeys)
@@ -193,9 +193,9 @@ class myModel extends model
}
else
{
$overview->myTaskTotal = (int)$this->dao->select('count(*) AS count')->from(TABLE_TASK)->where('assignedTo')->eq($this->app->user->account)->andWhere('deleted')->eq(0)->fetch('count');
$overview->myStoryTotal = (int)$this->dao->select('count(*) AS count')->from(TABLE_STORY)->where('assignedTo')->eq($this->app->user->account)->andWhere('deleted')->eq(0)->andWhere('type')->eq('story')->fetch('count');
$overview->myBugTotal = (int)$this->dao->select('count(*) AS count')->from(TABLE_BUG)->where('assignedTo')->eq($this->app->user->account)->andWhere('deleted')->eq(0)->fetch('count');
$overview->myTaskTotal = (int)$this->dao->select('COUNT(1) AS count')->from(TABLE_TASK)->where('assignedTo')->eq($this->app->user->account)->andWhere('deleted')->eq(0)->fetch('count');
$overview->myStoryTotal = (int)$this->dao->select('COUNT(1) AS count')->from(TABLE_STORY)->where('assignedTo')->eq($this->app->user->account)->andWhere('deleted')->eq(0)->andWhere('type')->eq('story')->fetch('count');
$overview->myBugTotal = (int)$this->dao->select('COUNT(1) AS count')->from(TABLE_BUG)->where('assignedTo')->eq($this->app->user->account)->andWhere('deleted')->eq(0)->fetch('count');
}
return $overview;
@@ -214,12 +214,12 @@ class myModel extends model
$inTeam = $this->dao->select('root')->from(TABLE_TEAM)->where('type')->eq('project')->andWhere('account')->eq($account)->fetchPairs('root', 'root');
$contribute = new stdclass();
$contribute->myTaskTotal = (int)$this->dao->select('count(*) AS count')->from(TABLE_TASK)->where('assignedTo')->eq($account)->andWhere('deleted')->eq(0)->fetch('count');
$contribute->myStoryTotal = (int)$this->dao->select('count(*) AS count')->from(TABLE_STORY)->where('assignedTo')->eq($account)->andWhere('deleted')->eq(0)->andWhere('type')->eq('story')->fetch('count');
$contribute->myBugTotal = (int)$this->dao->select('count(*) AS count')->from(TABLE_BUG)->where('assignedTo')->eq($account)->andWhere('deleted')->eq(0)->fetch('count');
$contribute->docCreatedTotal = (int)$this->dao->select('count(*) AS count')->from(TABLE_DOC)->where('addedBy')->eq($account)->andWhere('deleted')->eq('0')->fetch('count');
$contribute->ownerProductTotal = (int)$this->dao->select('count(*) AS count')->from(TABLE_PRODUCT)->where('PO')->eq($account)->andWhere('deleted')->eq('0')->fetch('count');
$contribute->involvedProjectTotal = (int)$this->dao->select('count(*) AS count')->from(TABLE_PROJECT)
$contribute->myTaskTotal = (int)$this->dao->select('COUNT(1) AS count')->from(TABLE_TASK)->where('assignedTo')->eq($account)->andWhere('deleted')->eq(0)->fetch('count');
$contribute->myStoryTotal = (int)$this->dao->select('COUNT(1) AS count')->from(TABLE_STORY)->where('assignedTo')->eq($account)->andWhere('deleted')->eq(0)->andWhere('type')->eq('story')->fetch('count');
$contribute->myBugTotal = (int)$this->dao->select('COUNT(1) AS count')->from(TABLE_BUG)->where('assignedTo')->eq($account)->andWhere('deleted')->eq(0)->fetch('count');
$contribute->docCreatedTotal = (int)$this->dao->select('COUNT(1) AS count')->from(TABLE_DOC)->where('addedBy')->eq($account)->andWhere('deleted')->eq('0')->fetch('count');
$contribute->ownerProductTotal = (int)$this->dao->select('COUNT(1) AS count')->from(TABLE_PRODUCT)->where('PO')->eq($account)->andWhere('deleted')->eq('0')->fetch('count');
$contribute->involvedProjectTotal = (int)$this->dao->select('COUNT(1) AS count')->from(TABLE_PROJECT)
->where('deleted')->eq('0')
->andWhere('type')->eq('project')
->andWhere('id', true)->in($inTeam)
+1 -1
View File
@@ -485,7 +485,7 @@ class personnelModel extends model
/* Append object count. */
if($objectType == 'sprint') $objectType = 'execution';
$countPairs = $this->dao->select('root, COUNT(*) as count')->from(TABLE_TEAM)
$countPairs = $this->dao->select('root, COUNT(1) AS count')->from(TABLE_TEAM)
->where('type')->eq($objectType)
->andWhere('root')->in(array_keys($objects))
->beginIF($objectType == 'execution')->orWhere('(type')->eq('project')->andWhere('root')->eq($parentID)->markRight(1)->fi()
+1 -1
View File
@@ -294,7 +294,7 @@ EOT)->from(TABLE_TASK)->alias('t1')
*/
protected function getAssignBugGroup(): array
{
return $this->dao->select('product, assignedTo, COUNT(*) AS bugCount')->from(TABLE_BUG)
return $this->dao->select('product, assignedTo, COUNT(1) AS bugCount')->from(TABLE_BUG)
->where('deleted')->eq('0')
->andWhere('status')->eq('active')
->andWhere('assignedTo')->ne('')
+11 -11
View File
@@ -244,7 +244,7 @@ class productTao extends productModel
$this->app->loadClass('date', true);
$weekDate = date::getThisWeek();
$fields = 'product,count(*) AS count';
$fields = 'product,COUNT(1) AS count';
$tableName = zget($this->config->objectTables, $type, TABLE_BUG);
if($type == 'plans') $tableName = TABLE_PRODUCTPLAN;
if($type == 'releases') $tableName = TABLE_RELEASE;
@@ -531,22 +531,22 @@ class productTao extends productModel
{
case TABLE_PRODUCTPLAN:
/* Get unclosed plans count. */
return $this->dao->select('COUNT(*) AS count')->from(TABLE_PRODUCTPLAN)->where('deleted')->eq('0')->andWhere('product')->eq("$productID")->andWhere('end')->gt(helper::now())->fetch('count');
return $this->dao->select('COUNT(1) AS count')->from(TABLE_PRODUCTPLAN)->where('deleted')->eq('0')->andWhere('product')->eq("$productID")->andWhere('end')->gt(helper::now())->fetch('count');
case TABLE_BUILD:
/* Get builds count. */
return $this->dao->select('COUNT(*) AS count')->from(TABLE_BUILD)->where('product')->eq("$productID")->andWhere('deleted')->eq('0')->fetch('count');
return $this->dao->select('COUNT(1) AS count')->from(TABLE_BUILD)->where('product')->eq("$productID")->andWhere('deleted')->eq('0')->fetch('count');
case TABLE_CASE:
/* Get cases count. */
return $this->dao->select('COUNT(*) AS count')->from(TABLE_CASE)->where('product')->eq("$productID")->andWhere('deleted')->eq('0')->fetch('count');
return $this->dao->select('COUNT(1) AS count')->from(TABLE_CASE)->where('product')->eq("$productID")->andWhere('deleted')->eq('0')->fetch('count');
case TABLE_BUG:
/* Get bugs count. */
return $this->dao->select('COUNT(*) AS count')->from(TABLE_BUG)->where('product')->eq("$productID")->andWhere('deleted')->eq('0')->fetch('count');
return $this->dao->select('COUNT(1) AS count')->from(TABLE_BUG)->where('product')->eq("$productID")->andWhere('deleted')->eq('0')->fetch('count');
case TABLE_DOC:
/* Get docs count. */
return $this->dao->select('COUNT(*) AS count')->from(TABLE_DOC)->where('product')->eq("$productID")->andWhere('deleted')->eq('0')->fetch('count');
return $this->dao->select('COUNT(1) AS count')->from(TABLE_DOC)->where('product')->eq("$productID")->andWhere('deleted')->eq('0')->fetch('count');
case TABLE_RELEASE:
/* Get releases count. */
return $this->dao->select('COUNT(*) AS count')->from(TABLE_RELEASE)->where('deleted')->eq('0')->andWhere('product')->eq("$productID")->fetch('count');
return $this->dao->select('COUNT(1) AS count')->from(TABLE_RELEASE)->where('deleted')->eq('0')->andWhere('product')->eq("$productID")->fetch('count');
case TABLE_PROJECTPRODUCT:
return $this->dao->select('COUNT(DISTINCT(t1.project)) AS count')
->from(TABLE_PROJECTPRODUCT)->alias('t1')
@@ -556,7 +556,7 @@ class productTao extends productModel
->andWhere('t2.type')->eq('project')
->fetch('count');
case 'executions':
return $this->dao->select('COUNT(*) AS count')
return $this->dao->select('COUNT(1) AS count')
->from(TABLE_PROJECTPRODUCT)->alias('t1')
->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project = t2.id')
->where('t2.deleted')->eq('0')
@@ -689,7 +689,7 @@ class productTao extends productModel
*/
protected function getExecutionCountPairs(array $productIdList): array
{
return $this->dao->select('t1.product, COUNT(*) AS count')
return $this->dao->select('t1.product, COUNT(1) AS count')
->from(TABLE_PROJECTPRODUCT)->alias('t1')
->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project = t2.id')
->where('t2.deleted')->eq('0')
@@ -710,7 +710,7 @@ class productTao extends productModel
*/
protected function getProjectCountPairs(array $productIdList): array
{
return $this->dao->select('t1.product, COUNT(*) AS count')
return $this->dao->select('t1.product, COUNT(1) AS count')
->from(TABLE_PROJECTPRODUCT)->alias('t1')
->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project = t2.id')
->where('t2.deleted')->eq('0')
@@ -731,7 +731,7 @@ class productTao extends productModel
*/
protected function getCaseCountByStoryIdList(array $storyIdList): array
{
return $this->dao->select('story, COUNT(*) AS count')
return $this->dao->select('story, COUNT(1) AS count')
->from(TABLE_CASE)
->where('deleted')->eq('0')
->andWhere('story')->in($storyIdList)
+1 -1
View File
@@ -439,7 +439,7 @@ class programModel extends model
$executions = $this->loadModel('project')->getExecutionList(array_keys($projects));
if($this->cookie->projectType && $this->cookie->projectType == 'bycard')
{
$leftTasks = $this->dao->select('t2.parent as project, count(*) as tasks')->from(TABLE_TASK)->alias('t1')
$leftTasks = $this->dao->select('t2.parent as project, COUNT(1) AS tasks')->from(TABLE_TASK)->alias('t1')
->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.execution = t2.id')
->where('t1.execution')->in(array_keys($executions))
->andWhere('t1.status')->notIn('cancel,closed')
+1 -1
View File
@@ -322,7 +322,7 @@ class programplanTao extends programplanModel
*/
protected function getStageCount(int $planID, string $mode = ''): int
{
return $this->dao->select('COUNT(*) AS count')->from(TABLE_PROJECT)
return $this->dao->select('COUNT(1) AS count')->from(TABLE_PROJECT)
->where('parent')->eq($planID)
->andWhere('type')->eq('stage')
->beginIF($mode == 'milestone')->andWhere('milestone')->eq(1)->fi()
+2 -2
View File
@@ -540,7 +540,7 @@ class projectModel extends model
->andWhere('deleted')->eq(0)
->fetch('bugCount');
$taskCount = $this->dao->select('count(*) as count,
$taskCount = $this->dao->select('COUNT(1) AS count,
sum(case when status = "wait" then 1 else 0 end) as waitCount,
sum(case when status = "doing" then 1 else 0 end) as doingCount,
sum(case when finishedBy != "" then 1 else 0 end) as finishedCount')->from(TABLE_TASK)
@@ -1154,7 +1154,7 @@ class projectModel extends model
*/
public function checkDates($projectID, $project): bool
{
$executionsCount = $this->dao->select('COUNT(*) as count')->from(TABLE_PROJECT)
$executionsCount = $this->dao->select('COUNT(1) AS count')->from(TABLE_PROJECT)
->where('project') ->eq($projectID)
->andWhere('deleted') ->eq('0')
->fetch('count');
+5 -5
View File
@@ -238,7 +238,7 @@ class reportModel extends model
*/
public function getUserYearLogins(array $accounts, string $year): int
{
return $this->dao->select('count(*) as count')->from(TABLE_ACTION)->where('actor')->in($accounts)->andWhere('LEFT(date, 4)')->eq($year)->andWhere('action')->eq('login')->fetch('count');
return $this->dao->select('COUNT(1) AS count')->from(TABLE_ACTION)->where('actor')->in($accounts)->andWhere('LEFT(date, 4)')->eq($year)->andWhere('action')->eq('login')->fetch('count');
}
/**
@@ -252,7 +252,7 @@ class reportModel extends model
*/
public function getUserYearActions(array $accounts, string $year): int
{
return $this->dao->select('count(*) as count')->from(TABLE_ACTION)
return $this->dao->select('COUNT(1) AS count')->from(TABLE_ACTION)
->where('LEFT(date, 4)')->eq($year)
->beginIF($accounts)->andWhere('actor')->in($accounts)->fi()
->fetch('count');
@@ -308,7 +308,7 @@ class reportModel extends model
$contributions[$type][$actionName] += 1;
}
}
$contributions['case']['run'] = $this->dao->select('count(*) as count')->from(TABLE_TESTRESULT)->alias('t1')
$contributions['case']['run'] = $this->dao->select('COUNT(1) AS count')->from(TABLE_TESTRESULT)->alias('t1')
->leftJoin(TABLE_CASE)->alias('t2')->on('t1.case=t2.id')
->where('LEFT(t1.date, 4)')->eq($year)
->andWhere('t2.deleted')->eq(0)
@@ -328,7 +328,7 @@ class reportModel extends model
*/
public function getUserYearTodos(array $accounts, string $year): object
{
return $this->dao->select("count(*) as count, sum(if((`status` != 'done'), 1, 0)) AS `undone`, sum(if((`status` = 'done'), 1, 0)) AS `done`")->from(TABLE_TODO)
return $this->dao->select("COUNT(1) AS count, sum(if((`status` != 'done'), 1, 0)) AS `undone`, sum(if((`status` = 'done'), 1, 0)) AS `done`")->from(TABLE_TODO)
->where('LEFT(date, 4)')->eq($year)
->andWhere('deleted')->eq('0')
->andWhere('vision')->eq($this->config->vision)
@@ -347,7 +347,7 @@ class reportModel extends model
*/
public function getUserYearEfforts(array $accounts, string $year): object
{
$effort = $this->dao->select('count(*) as count, sum(consumed) as consumed')->from(TABLE_EFFORT)
$effort = $this->dao->select('COUNT(1) AS count, sum(consumed) as consumed')->from(TABLE_EFFORT)
->where('LEFT(date, 4)')->eq($year)
->andWhere('deleted')->eq(0)
->beginIF($accounts)->andWhere('account')->in($accounts)->fi()
+3 -3
View File
@@ -81,7 +81,7 @@ class reportTao extends reportModel
->andWhere('t2.multiple')->eq('1')
->andWhere('LEFT(`join`, 4)')->eq($year)
->fetchPairs();
$taskStats = $this->dao->select('execution, count(*) as finishedTask, sum(if((story != 0), 1, 0)) as finishedStory')->from(TABLE_TASK)
$taskStats = $this->dao->select('execution, COUNT(1) AS finishedTask, sum(if((story != 0), 1, 0)) as finishedStory')->from(TABLE_TASK)
->where('deleted')->eq(0)
->andWhere('(finishedBy', true)->ne('')
->andWhere('LEFT(finishedDate, 4)')->eq($year)
@@ -110,7 +110,7 @@ class reportTao extends reportModel
->orderBy('`order` desc')
->fetchAll('id');
/* Get resolved bugs in this year. */
$resolvedBugs = $this->dao->select('t2.execution, count(*) as count')->from(TABLE_BUG)->alias('t1')
$resolvedBugs = $this->dao->select('t2.execution, COUNT(1) AS count')->from(TABLE_BUG)->alias('t1')
->leftJoin(TABLE_BUILD)->alias('t2')->on('t1.resolvedBuild=t2.id')
->where('t1.deleted')->eq(0)
->andWhere('t2.execution')->in(array_keys($executions))
@@ -236,7 +236,7 @@ class reportTao extends reportModel
->andWhere('t2.case')->ne('0')
->beginIF($accounts)->andWhere('t1.actor')->in($accounts)->fi()
->fetch('count');
$outputData['case']['run'] = $this->dao->select('count(*) as count')->from(TABLE_TESTRESULT)->alias('t1')
$outputData['case']['run'] = $this->dao->select('COUNT(1) AS count')->from(TABLE_TESTRESULT)->alias('t1')
->leftJoin(TABLE_CASE)->alias('t2')->on('t1.case=t2.id')
->where('LEFT(t1.date, 4)')->eq($year)
->andWhere('t2.deleted')->eq(0)
+1 -1
View File
@@ -486,7 +486,7 @@ class searchModel extends model
$filterObjects[] = $object;
}
$typeCount = $this->dao->select("objectType, count(*) AS objectCount")->from(TABLE_SEARCHINDEX)
$typeCount = $this->dao->select("objectType, COUNT(1) AS objectCount")->from(TABLE_SEARCHINDEX)
->where('((vision')->eq($this->config->vision)
->andWhere('objectType')->in($allowedObjects)
->markRight(1)
@@ -126,7 +126,7 @@ class searchTest
global $tester;
$table = $tester->config->objectTables[$objectType];
$query->queryCount = $tester->dao->select('count(*) AS count')->from($table)->where($query->sql)->fetch('count');
$query->queryCount = $tester->dao->select('COUNT(1) AS count')->from($table)->where($query->sql)->fetch('count');
if(dao::isError()) return dao::getError();
@@ -203,7 +203,7 @@ class searchTest
if(dao::isError()) return dao::getError();
global $tester;
$count = $tester->dao->select('count(*) AS count')->from(TABLE_USERQUERY)->fetch('count');
$count = $tester->dao->select('COUNT(1) AS count')->from(TABLE_USERQUERY)->fetch('count');
if(dao::isError()) return dao::getError();
return $count;
}
@@ -401,7 +401,7 @@ class searchTest
$this->objectModel->deleteIndex($objectType, $objectID);
global $tester;
return $tester->dao->select('count(*) AS count')->from(TABLE_SEARCHINDEX)->where('objectType')->eq($objectType)->andWhere('objectID')->eq($objectID)->fetch('count');
return $tester->dao->select('COUNT(1) AS count')->from(TABLE_SEARCHINDEX)->where('objectType')->eq($objectType)->andWhere('objectID')->eq($objectID)->fetch('count');
}
/**
@@ -96,7 +96,7 @@ class settingTest
if(dao::isError()) return dao::getError();
return $this->objectModel->dao->select('count(*) as count')->from(TABLE_CONFIG)->fetch('count');
return $this->objectModel->dao->select('COUNT(1) AS count')->from(TABLE_CONFIG)->fetch('count');
}
/**
+2 -2
View File
@@ -3480,7 +3480,7 @@ class storyModel extends model
*/
public function getDataOfStoriesPerChange(string $storyType = 'story'): array
{
return $this->dao->select('(version-1) as name, count(*) as value')->from(TABLE_STORY)
return $this->dao->select('(version-1) as name, COUNT(1) AS value')->from(TABLE_STORY)
->where($this->reportCondition($storyType))
->groupBy('version')->orderBy('value')
->fetchAll();
@@ -3496,7 +3496,7 @@ class storyModel extends model
*/
public function getDataOfStoriesPerGrade(string $storyType = 'story'): array
{
$datas = $this->dao->select('type, grade as name, count(*) as count')->from(TABLE_STORY)
$datas = $this->dao->select('type, grade as name, COUNT(1) AS count')->from(TABLE_STORY)
->where($this->reportCondition($storyType))
->groupBy('type,name')
->fetchGroup('type', 'name');
+1 -1
View File
@@ -379,7 +379,7 @@ class taskModel extends model
if($isParentChanged)
{
$oldChildCount = $this->dao->select('count(*) as count')->from(TABLE_TASK)->where('parent')->eq($oldTask->parent)->fetch('count');
$oldChildCount = $this->dao->select('COUNT(1) AS count')->from(TABLE_TASK)->where('parent')->eq($oldTask->parent)->fetch('count');
if(!$oldChildCount) $this->dao->update(TABLE_TASK)->set('parent')->eq(0)->where('id')->eq($oldTask->parent)->exec();
$this->dao->update(TABLE_TASK)->set('lastEditedBy')->eq($this->app->user->account)->set('lastEditedDate')->eq(helper::now())->where('id')->eq($oldTask->parent)->exec();
$this->loadModel('action')->create('task', $task->id, 'unlinkParentTask', '', $oldTask->parent, '', false);
+1 -1
View File
@@ -244,7 +244,7 @@ class taskTao extends taskModel
*/
protected function checkHasChildren(int $taskID): bool
{
$childrenCount = $this->dao->select('count(*) as count')->from(TABLE_TASK)->where('parent')->eq($taskID)->fetch('count');
$childrenCount = $this->dao->select('COUNT(1) AS count')->from(TABLE_TASK)->where('parent')->eq($taskID)->fetch('count');
if(!$childrenCount) return false;
return true;
}
+1 -1
View File
@@ -1555,7 +1555,7 @@ class testcase extends control
public function deleteScene(int $sceneID, string $confirm = 'no')
{
$scene = $this->testcase->getSceneByID($sceneID);
$count = $this->dao->select('COUNT(*) AS count')->from(TABLE_SCENE)->where('deleted')->eq('0')->andWhere('parent')->eq($sceneID)->fetch('count');
$count = $this->dao->select('COUNT(1) AS count')->from(TABLE_SCENE)->where('deleted')->eq('0')->andWhere('parent')->eq($sceneID)->fetch('count');
if($count)
{
if($confirm != 'yes')
+5 -5
View File
@@ -497,7 +497,7 @@ class testcaseModel extends model
{
if(empty($stories)) return array();
$caseCounts = $this->dao->select('story, COUNT(*) AS cases')
$caseCounts = $this->dao->select('story, COUNT(1) AS cases')
->from(TABLE_CASE)
->where('story')->in($stories)
->andWhere('deleted')->eq(0)
@@ -1342,13 +1342,13 @@ class testcaseModel extends model
/* 查询用例的 bugs 和结果。 */
/* Get bugs and results. */
$queryField = $type == 'case' ? '`case`' : '`result`';
$caseBugs = $this->dao->select('COUNT(*) AS count, `case`')->from(TABLE_BUG)->where($queryField)->in($caseIdList)->andWhere('deleted')->eq(0)->groupBy('`case`')->fetchPairs('case', 'count');
$results = $this->dao->select('COUNT(*) AS count, `case`')->from(TABLE_TESTRESULT)->where('`case`')->in($caseIdList)->groupBy('`case`')->fetchPairs('case', 'count');
$caseBugs = $this->dao->select('COUNT(1) AS count, `case`')->from(TABLE_BUG)->where($queryField)->in($caseIdList)->andWhere('deleted')->eq(0)->groupBy('`case`')->fetchPairs('case', 'count');
$results = $this->dao->select('COUNT(1) AS count, `case`')->from(TABLE_TESTRESULT)->where('`case`')->in($caseIdList)->groupBy('`case`')->fetchPairs('case', 'count');
/* 查询用例的失败结果。 */
/* Get result fails of the the testcases. */
if($type != 'case') $queryField = '`run`';
$caseFails = $this->dao->select('COUNT(*) AS count, `case`')->from(TABLE_TESTRESULT)
$caseFails = $this->dao->select('COUNT(1) AS count, `case`')->from(TABLE_TESTRESULT)
->where('caseResult')->eq('fail')
->andWhere($queryField)->in($caseIdList)
->groupBy('`case`')
@@ -2520,7 +2520,7 @@ class testcaseModel extends model
*/
public function appendCaseFails(object $case, string $from, int $taskID): object
{
$caseFails = $this->dao->select('COUNT(*) AS count')->from(TABLE_TESTRESULT)
$caseFails = $this->dao->select('COUNT(1) AS count')->from(TABLE_TESTRESULT)
->where('caseResult')->eq('fail')
->andwhere('`case`')->eq($case->id)
->beginIF($from == 'testtask')->andwhere('`run`')->eq($taskID)->fi()
@@ -946,7 +946,7 @@ class testcaseTest
if(dao::isError()) return false;
return $tester->dao->select('count(*) AS count')->from(TABLE_TESTRUN)->where('`case`')->eq($caseID)->andWhere('task')->in(array_keys($testtasks))->fetch('count');
return $tester->dao->select('COUNT(1) AS count')->from(TABLE_TESTRUN)->where('`case`')->eq($caseID)->andWhere('task')->in(array_keys($testtasks))->fetch('count');
}
/**
+3 -3
View File
@@ -577,7 +577,7 @@ class testtaskModel extends model
*/
public function getDataOfTestTaskPerType(int $taskID): array
{
$datas = $this->dao->select('t2.type AS name, COUNT(*) AS value')->from(TABLE_TESTRUN)->alias('t1')
$datas = $this->dao->select('t2.type AS name, COUNT(1) AS value')->from(TABLE_TESTRUN)->alias('t1')
->leftJoin(TABLE_CASE)->alias('t2')->on('t1.case = t2.id')
->where('t1.task')->eq($taskID)
->andWhere('t2.deleted')->eq('0')
@@ -601,7 +601,7 @@ class testtaskModel extends model
*/
public function getDataOfTestTaskPerModule(int $taskID): array
{
$datas = $this->dao->select('t2.module AS name, COUNT(*) AS value')->from(TABLE_TESTRUN)->alias('t1')
$datas = $this->dao->select('t2.module AS name, COUNT(1) AS value')->from(TABLE_TESTRUN)->alias('t1')
->leftJoin(TABLE_CASE)->alias('t2')->on('t1.case = t2.id')
->where('t1.task')->eq($taskID)
->andWhere('t2.deleted')->eq('0')
@@ -626,7 +626,7 @@ class testtaskModel extends model
*/
public function getDataOfTestTaskPerRunner($taskID)
{
$datas = $this->dao->select('t1.lastRunner AS name, COUNT(*) AS value')->from(TABLE_TESTRUN)->alias('t1')
$datas = $this->dao->select('t1.lastRunner AS name, COUNT(1) AS value')->from(TABLE_TESTRUN)->alias('t1')
->leftJoin(TABLE_CASE)->alias('t2')->on('t1.case = t2.id')
->where('t1.task')->eq($taskID)
->andWhere('t2.deleted')->eq('0')
@@ -182,7 +182,7 @@ class testtaskTest
if(dao::isError()) return dao::getError();
if(!$result) return $result;
$run = $this->objectModel->dao->select('COUNT(*) AS count')->from(TABLE_TESTRUN)->where('id')->eq($runID)->fetch('count');
$run = $this->objectModel->dao->select('COUNT(1) AS count')->from(TABLE_TESTRUN)->where('id')->eq($runID)->fetch('count');
$cases = $this->objectModel->dao->select('project, `case`')->from(TABLE_PROJECTCASE)->fetchAll();
$action = $this->objectModel->dao->select('*')->from(TABLE_ACTION)->orderBy('id_desc')->limit(1)->fetch();
+2 -2
View File
@@ -47,7 +47,7 @@ class todoTao extends todoModel
*/
protected function getCountByAccount(string $account, string $vision = 'rnd'): int
{
return $this->dao->select('COUNT(*) AS count')->from(TABLE_TODO)
return $this->dao->select('COUNT(1) AS count')->from(TABLE_TODO)
->where('cycle')->eq('0')
->andWhere('deleted')->eq('0')
->andWhere('vision')->eq($vision)
@@ -364,7 +364,7 @@ class todoTao extends todoModel
*/
protected function getTodoCountByAccount(string $account): int
{
return $this->dao->select('COUNT(*) AS count')->from(TABLE_TODO)
return $this->dao->select('COUNT(1) AS count')->from(TABLE_TODO)
->where('cycle')->eq('0')
->andWhere('deleted')->eq('0')
->andWhere('vision')->eq($this->config->vision)
+1 -1
View File
@@ -25,7 +25,7 @@ class tutorialModel extends model
if($account == 'guest') return false;
if(!empty($this->app->user->modifyPassword)) return false;
$count = $this->dao->select('count(*) AS count')->from(TABLE_ACTION)->where('actor')->eq($account)->fetch('count');
$count = $this->dao->select('COUNT(1) AS count')->from(TABLE_ACTION)->where('actor')->eq($account)->fetch('count');
if($count < 10) return true;
$this->loadModel('setting')->setItem($account . '.common.global.novice', 0);
+5 -5
View File
@@ -2821,7 +2821,7 @@ class upgradeModel extends model
*/
public function addUniqueKeyToTeam()
{
$members = $this->dao->select('root, type, account')->from(TABLE_TEAM)->groupBy('root, type, account')->having('count(*)')->gt(1)->fetchAll();
$members = $this->dao->select('root, type, account')->from(TABLE_TEAM)->groupBy('root, type, account')->having('count(1)')->gt(1)->fetchAll();
foreach($members as $member)
{
@@ -3054,7 +3054,7 @@ class upgradeModel extends model
*/
public function adjustWebhookType()
{
$bearychatCount = $this->dao->select('count(*) as count')->from(TABLE_WEBHOOK)->where('type')->eq('bearychat')->fetch('count');
$bearychatCount = $this->dao->select('COUNT(1) AS count')->from(TABLE_WEBHOOK)->where('type')->eq('bearychat')->fetch('count');
if($bearychatCount)
{
$item = new stdclass();
@@ -8390,7 +8390,7 @@ class upgradeModel extends model
*/
public function getNoMergedProductCount(): int
{
return (int)$this->dao->select('count(*) AS count')->from(TABLE_PRODUCT)->where('program')->eq(0)->andWhere('vision')->eq('rnd')->fetch('count');
return (int)$this->dao->select('COUNT(1) AS count')->from(TABLE_PRODUCT)->where('program')->eq(0)->andWhere('vision')->eq('rnd')->fetch('count');
}
/**
@@ -8402,7 +8402,7 @@ class upgradeModel extends model
*/
public function getNoMergedSprintCount(): int
{
return (int)$this->dao->select('count(*) AS count')->from(TABLE_PROJECT)->where('vision')->eq('rnd')->andWhere('project')->eq(0)->andWhere('type')->eq('sprint')->andWhere('deleted')->eq('0')->fetch('count');
return (int)$this->dao->select('COUNT(1) AS count')->from(TABLE_PROJECT)->where('vision')->eq('rnd')->andWhere('project')->eq(0)->andWhere('type')->eq('sprint')->andWhere('deleted')->eq('0')->fetch('count');
}
/**
@@ -8606,7 +8606,7 @@ class upgradeModel extends model
*/
public function update18101(): void
{
$count = $this->dao->select('COUNT(*) AS count')->from('information_schema.TABLES')->where('TABLE_SCHEMA')->eq($this->config->db->name)->andWhere('TABLE_NAME')->eq(str_replace('`', '', TABLE_AI_MODEL))->fetch('count');
$count = $this->dao->select('COUNT(1) AS count')->from('information_schema.TABLES')->where('TABLE_SCHEMA')->eq($this->config->db->name)->andWhere('TABLE_NAME')->eq(str_replace('`', '', TABLE_AI_MODEL))->fetch('count');
if($count) return;
/* Execute open edition. */