gpt4 book ai didi

php - mantisBT 插件 GaugeSupport 错误 #1111 : Invalid use of group function

转载 作者:行者123 更新时间:2023-11-29 03:31:18 24 4
gpt4 key购买 nike

我将 mantisBT 1.2.19 用于错误跟踪项目 http://mantisbt.org/download.php .

此外,我使用插件 gaugeSupport 来支持用户对错误进行投票以进行错误排名 (https://github.com/EvilRenegade/Gauge-Support)

该插件不适用于我的螳螂项目:

在插件文件 issue_ranking.php 中,有 MySQL 查询:

$dbquery = "SELECT  
max(sd.bugid) as bugid,
count(sd.rating) as no_of_ratings,
sum(sd.rating) as sum_of_ratings,
avg(sd.rating) as avg_rating,
max(sd.rating) as highest_rating,
min(sd.rating) as lowest_rating,
IFNULL(bm2_count,0) AS bm2_count,
IFNULL(bm2_sum,0) AS bm2_sum,
IFNULL(bm1_count,0) AS bm1_count,
IFNULL(bm1_sum,0) AS bm1_sum,
IFNULL(b2_count,0) AS b2_count,
IFNULL(b2_sum,0) AS b2_sum,
IFNULL(b1_count,0) AS b1_count,
IFNULL(b1_sum,0) AS b1_sum
FROM {$plugin_table} sd
INNER JOIN {$bug_table} b ON sd.bugid = b.id
LEFT OUTER JOIN (SELECT bugid, count(rating) as bm2_count, sum(rating) as bm2_sum FROM {$plugin_table} GROUP BY bugid, rating HAVING rating = -2) bm2 ON sd.bugid = bm2.bugid
LEFT OUTER JOIN (SELECT bugid, count(rating) as bm1_count, sum(rating) as bm1_sum FROM {$plugin_table} GROUP BY bugid, rating HAVING rating = -1) bm1 ON sd.bugid = bm1.bugid
LEFT OUTER JOIN (SELECT bugid, count(rating) as b2_count, sum(rating) as b2_sum FROM {$plugin_table} GROUP BY bugid, rating HAVING rating = 2) b2 ON sd.bugid = b2.bugid
LEFT OUTER JOIN (SELECT bugid, count(rating) as b1_count, sum(rating) as b1_sum FROM {$plugin_table} GROUP BY bugid, rating HAVING rating = 1) b1 ON sd.bugid = b1.bugid
{$where_clause}
GROUP BY sd.bugid
ORDER BY sum(sd.rating) {$order}
LIMIT {$start}{$noOfBugs}";

导致错误:

Database query failed. Error received from database was #1054: Unknown column 'rating' in 'having clause' for the query:  SELECT  
max(sd.bugid) as bugid,
count(sd.rating) as no_of_ratings,
sum(sd.rating) as sum_of_ratings,
avg(sd.rating) as avg_rating,
max(sd.rating) as highest_rating,
min(sd.rating) as lowest_rating,
IFNULL(bm2_count,0) AS bm2_count,
IFNULL(bm2_sum,0) AS bm2_sum,
IFNULL(bm1_count,0) AS bm1_count,
IFNULL(bm1_sum,0) AS bm1_sum,
IFNULL(b2_count,0) AS b2_count,
IFNULL(b2_sum,0) AS b2_sum,
IFNULL(b1_count,0) AS b1_count,
IFNULL(b1_sum,0) AS b1_sum
FROM mantis_plugin_GaugeSupport_support_data_table sd
INNER JOIN mantis_bug_table b ON sd.bugid = b.id
LEFT OUTER JOIN (SELECT bugid, count(rating) as bm2_count, sum(rating) as bm2_sum FROM mantis_plugin_GaugeSupport_support_data_table GROUP BY bugid, rating HAVING rating = -2) bm2 ON sd.bugid = bm2.bugid
LEFT OUTER JOIN (SELECT bugid, count(rating) as bm1_count, sum(rating) as bm1_sum FROM mantis_plugin_GaugeSupport_support_data_table GROUP BY bugid, rating HAVING rating = -1) bm1 ON sd.bugid = bm1.bugid
LEFT OUTER JOIN (SELECT bugid, count(rating) as b2_count, sum(rating) as b2_sum FROM mantis_plugin_GaugeSupport_support_data_table GROUP BY bugid, rating HAVING rating = 2) b2 ON sd.bugid = b2.bugid
LEFT OUTER JOIN (SELECT bugid, count(rating) as b1_count, sum(rating) as b1_sum FROM mantis_plugin_GaugeSupport_support_data_table GROUP BY bugid, rating HAVING rating = 1) b1 ON sd.bugid = b1.bugid
WHERE b.project_id = 1 AND b.resolution NOT IN (20,40,50,70,90) AND b.status != 90
GROUP BY sd.bugid
ORDER BY sum(sd.rating) DESC
LIMIT 0,10.

当我将列“rating”添加到查询时,我仍然得到错误使用 GROUP BY 函数的错误:

Database query failed. Error received from database was #1111: Invalid use of group function for the query:  SELECT  
max(sd.bugid) as bugid,
count(sd.rating) as no_of_ratings,
sum(sd.rating) as sum_of_ratings,
avg(sd.rating) as avg_rating,
max(sd.rating) as highest_rating,
min(sd.rating) as lowest_rating,
IFNULL(bm2_count,0) AS bm2_count,
IFNULL(bm2_sum,0) AS bm2_sum,
IFNULL(bm1_count,0) AS bm1_count,
IFNULL(bm1_sum,0) AS bm1_sum,
IFNULL(b2_count,0) AS b2_count,
IFNULL(b2_sum,0) AS b2_sum,
IFNULL(b1_count,0) AS b1_count,
IFNULL(b1_sum,0) AS b1_sum
FROM mantis_plugin_GaugeSupport_support_data_table sd
INNER JOIN mantis_bug_table b ON sd.bugid = b.id
LEFT OUTER JOIN (SELECT bugid, rating, count(rating) as bm2_count, sum(rating) as bm2_sum FROM mantis_plugin_GaugeSupport_support_data_table GROUP BY bugid, rating HAVING rating = -2) bm2 ON sd.bugid = bm2.bugid
LEFT OUTER JOIN (SELECT bugid, rating, count(rating) as bm1_count, sum(rating) as bm1_sum FROM mantis_plugin_GaugeSupport_support_data_table GROUP BY bugid, rating HAVING rating = -1) bm1 ON sd.bugid = bm1.bugid
LEFT OUTER JOIN (SELECT bugid, rating, count(rating) as b2_count, sum(rating) as b2_sum FROM mantis_plugin_GaugeSupport_support_data_table GROUP BY bugid, rating HAVING rating = 2) b2 ON sd.bugid = b2.bugid
LEFT OUTER JOIN (SELECT bugid, rating, count(rating) as b1_count, sum(rating) as b1_sum FROM mantis_plugin_GaugeSupport_support_data_table GROUP BY bugid, rating HAVING rating = 1) b1 ON sd.bugid = b1.bugid
WHERE b.project_id = 1 AND b.resolution NOT IN (20,40,50,70,90) AND b.status != 90
GROUP BY sd.bugid
ORDER BY sum(sd.rating) DESC
LIMIT 0,10.

有谁知道如何正确设置 Mantis 的 GaugeSupport 插件?

谢谢!

最佳答案

Abhik Chakraborty 的评论解决了这个问题:

"不能在order by子句中使用聚合函数只需使用按 sum_of_ratings 排序。

谢谢!

关于php - mantisBT 插件 GaugeSupport 错误 #1111 : Invalid use of group function,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30163767/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com