|
|
后台开启了“列表不重复公司信息”后,前台供应列表显示数量均不对,后来发现时sql错误
include/tag.func.php
103行[ol] $num = 0; $group = $group ? " GROUP BY $group" : ''; $order = $order ? " ORDER BY $order" : ''; $condition = stripslashes($condition); $condition = str_replace('##', '%', $condition); if($showpage) { $num = $db->count($table, $condition.$group, $tag_expires ? $tag_expires : $CFG['db_expires']);[/ol]复制代码在include/db_mysql.class.php
63行[ol] function count($table, $condition = '', $expires = 0) { global $DT_TIME; $sql = 'SELECT COUNT(*) as amount FROM '.$table; if($condition) $sql .= ' WHERE '.$condition;[/ol]复制代码如果开启“列表不重复公司信息”,此处的$condition=$condition.$group。
也就是说,SELECT COUNT(*) as amount FROM $table where *** group by username
但是这样的话,amount就是分组统计结果,如下图:
这样列表显示的就不是1240条结果,而是36条,同样的问题在别的地方也存在,都是COUNT(*)和group by 联合使用导致的。
请官方研究一下,给出一个合理的解决方案。谢谢! |
|