SELECT ... COUNT(p.post_id) AS total_posts
and ORDER BY total_posts DESC
, so he's grabbing the poster with the most posts in his first (and only) fetch.Code: Select all
$sql = 'SELECT u.username, u.user_id, u.user_colour, MAX(u.user_type), p.poster_id, MAX(p.post_time), COUNT(p.post_id) AS total_posts
FROM ' . USERS_TABLE . ' u, ' . POSTS_TABLE . ' p
WHERE u.user_id <> ' . ANONYMOUS . '
AND u.user_id = p.poster_id
AND (u.user_type <> ' . USER_FOUNDER . ')
AND ' . $this->db->sql_in_set('u.user_id', $admin_mod_array, true, true) . '
AND ' . $this->db->sql_in_set('u.user_id', $ban_ids, true, true) . '
AND p.post_visibility = ' . ITEM_APPROVED . '
AND p.post_time BETWEEN ' . $month_start . ' AND ' . $month_end . '
GROUP BY u.user_id
ORDER BY total_posts DESC';
$result = $this->db->sql_query_limit($sql, 1);
$row = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
SELECT @@sql_mode
and [CTRL] + [ENTER]STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION
ONLY_FULL_GROUP_BY
to it and your are now ready for tests.SET GLOBAL sql_mode = "STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,ONLY_FULL_GROUP_BY"