aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/ucp/ucp_main.php
diff options
context:
space:
mode:
authorDavid M <davidmj@users.sourceforge.net>2006-05-17 19:29:20 +0000
committerDavid M <davidmj@users.sourceforge.net>2006-05-17 19:29:20 +0000
commit5e1d4527e86c1014efd4d251af86cd3ec37cba8f (patch)
tree68424e4b4b6e479083007aab33cb83a7361ced0d /phpBB/includes/ucp/ucp_main.php
parent545bf57cb32920365e98b64ba7b99d51cbd01017 (diff)
downloadforums-5e1d4527e86c1014efd4d251af86cd3ec37cba8f.tar
forums-5e1d4527e86c1014efd4d251af86cd3ec37cba8f.tar.gz
forums-5e1d4527e86c1014efd4d251af86cd3ec37cba8f.tar.bz2
forums-5e1d4527e86c1014efd4d251af86cd3ec37cba8f.tar.xz
forums-5e1d4527e86c1014efd4d251af86cd3ec37cba8f.zip
This is a screwy world! Screwy I tell you!
git-svn-id: file:///svn/phpbb/trunk@5924 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/ucp/ucp_main.php')
-rw-r--r--phpBB/includes/ucp/ucp_main.php65
1 files changed, 52 insertions, 13 deletions
diff --git a/phpBB/includes/ucp/ucp_main.php b/phpBB/includes/ucp/ucp_main.php
index 716f459316..a75901457e 100644
--- a/phpBB/includes/ucp/ucp_main.php
+++ b/phpBB/includes/ucp/ucp_main.php
@@ -812,12 +812,31 @@ class ucp_main
$post_count_sql = (sizeof($forum_ary)) ? 'AND f.forum_id NOT IN (' . implode(', ', $forum_ary) . ')' : '';
- $sql = 'SELECT f.forum_id, COUNT(p.post_id) AS num_posts
- FROM ' . POSTS_TABLE . ' p, ' . FORUMS_TABLE . ' f
- WHERE p.poster_id = ' . $user->data['user_id'] . "
- AND f.forum_id = p.forum_id
- $post_count_sql
- GROUP BY f.forum_id";
+ // Firebird does not support ORDER BY on aliased columns
+ // MySQL does not support ORDER BY on functions
+ switch (SQL_LAYER)
+ {
+ case 'firebird':
+ $sql = 'SELECT f.forum_id, COUNT(p.post_id) AS num_posts
+ FROM ' . POSTS_TABLE . ' p, ' . FORUMS_TABLE . ' f
+ WHERE p.poster_id = ' . $user->data['user_id'] . "
+ AND f.forum_id = p.forum_id
+ $post_count_sql
+ GROUP BY f.forum_id
+ ORDER BY COUNT(p.post_id) DESC";
+ break;
+
+ default:
+ $sql = 'SELECT f.forum_id, COUNT(p.post_id) AS num_posts
+ FROM ' . POSTS_TABLE . ' p, ' . FORUMS_TABLE . ' f
+ WHERE p.poster_id = ' . $user->data['user_id'] . "
+ AND f.forum_id = p.forum_id
+ $post_count_sql
+ GROUP BY f.forum_id
+ ORDER BY num_posts DESC";
+ break;
+ }
+
$result = $db->sql_query_limit($sql, 1);
$active_f_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
@@ -830,13 +849,33 @@ class ucp_main
$db->sql_freeresult($result);
$active_f_row['forum_name'] = $row['forum_name'];
- $sql = 'SELECT t.topic_id, COUNT(p.post_id) AS num_posts
- FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . ' f
- WHERE p.poster_id = ' . $user->data['user_id'] . "
- AND t.topic_id = p.topic_id
- AND f.forum_id = t.forum_id
- $post_count_sql
- GROUP BY t.topic_id";
+ // Firebird does not support ORDER BY on aliased columns
+ // MySQL does not support ORDER BY on functions
+ switch (SQL_LAYER)
+ {
+ case 'firebird':
+ $sql = 'SELECT t.topic_id, COUNT(p.post_id) AS num_posts
+ FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . ' f
+ WHERE p.poster_id = ' . $user->data['user_id'] . "
+ AND t.topic_id = p.topic_id
+ AND f.forum_id = t.forum_id
+ $post_count_sql
+ GROUP BY t.topic_id
+ ORDER BY COUNT(p.post_id) DESC";
+ break;
+
+ default:
+ $sql = 'SELECT t.topic_id, COUNT(p.post_id) AS num_posts
+ FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . ' f
+ WHERE p.poster_id = ' . $user->data['user_id'] . "
+ AND t.topic_id = p.topic_id
+ AND f.forum_id = t.forum_id
+ $post_count_sql
+ GROUP BY t.topic_id
+ ORDER BY num_posts DESC";
+ break;
+ }
+
$result = $db->sql_query_limit($sql, 1);
$active_t_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);