aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorDavid M <davidmj@users.sourceforge.net>2007-08-13 05:20:20 +0000
committerDavid M <davidmj@users.sourceforge.net>2007-08-13 05:20:20 +0000
commitea636f16eeafdd87027a2f95b79b50608b269282 (patch)
tree460b2536262188acbc8a0b66a715f188bac49ce1 /phpBB
parent3f9348bdf8ccc05f251b85caccaf5a241ae011fc (diff)
downloadforums-ea636f16eeafdd87027a2f95b79b50608b269282.tar
forums-ea636f16eeafdd87027a2f95b79b50608b269282.tar.gz
forums-ea636f16eeafdd87027a2f95b79b50608b269282.tar.bz2
forums-ea636f16eeafdd87027a2f95b79b50608b269282.tar.xz
forums-ea636f16eeafdd87027a2f95b79b50608b269282.zip
remove the need for filesorting
git-svn-id: file:///svn/phpbb/trunk@8023 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/viewtopic.php21
1 files changed, 14 insertions, 7 deletions
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php
index afa818fdc3..1b0b6336af 100644
--- a/phpBB/viewtopic.php
+++ b/phpBB/viewtopic.php
@@ -109,13 +109,20 @@ if ($view && !$post_id)
$sql_condition = ($view == 'next') ? '>' : '<';
$sql_ordering = ($view == 'next') ? 'ASC' : 'DESC';
- $sql = 'SELECT t.topic_id, t.forum_id
- FROM ' . TOPICS_TABLE . ' t
- LEFT JOIN ' . TOPICS_TABLE . " t2 ON (t2.topic_id = $topic_id AND t.forum_id = t2.forum_id)
- WHERE t.topic_last_post_time $sql_condition t2.topic_last_post_time
- " . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND t.topic_approved = 1') . "
- AND t.topic_moved_id = 0
- ORDER BY t.topic_last_post_time $sql_ordering";
+ $sql = 'SELECT forum_id, topic_last_post_time
+ FROM ' . TOPICS_TABLE . '
+ WHERE topic_id = ' . $topic_id;
+ $result = $db->sql_query($sql);
+ $row = $db->sql_fetchrow($result);
+ $db->sql_freeresult($result);
+
+ $sql = 'SELECT topic_id, forum_id
+ FROM ' . TOPICS_TABLE . '
+ WHERE forum_id = ' . $row['forum_id'] . "
+ AND topic_moved_id = 0
+ AND topic_last_post_time $sql_condition {$row['topic_last_post_time']}
+ " . (($auth->acl_get('m_approve', $row['forum_id']) && false) ? '' : 'AND topic_approved = 1') . "
+ ORDER BY topic_last_post_time $sql_ordering";
$result = $db->sql_query_limit($sql, 1);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);