From 4e503c05089bacf2cf070eebd24d6a358be35510 Mon Sep 17 00:00:00 2001 From: Ludovic Arnaud Date: Thu, 6 Mar 2003 02:36:04 +0000 Subject: [PATCH] Switched up $total and $offset as per MySQL manual git-svn-id: file:///svn/phpbb/trunk@3606 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/db/mysql.php | 28 +++++++++++++++------------- phpBB/viewtopic.php | 5 +---- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/phpBB/db/mysql.php b/phpBB/db/mysql.php index 121d6be748..fe18cffa89 100644 --- a/phpBB/db/mysql.php +++ b/phpBB/db/mysql.php @@ -209,21 +209,23 @@ class sql_db return ($this->query_result) ? $this->query_result : false; } - function sql_query_limit($query, $total, $offset = 0, $expire_time = 0) - { - if ($query != '') - { - $this->query_result = false; - $this->num_queries++; + // 20030406 Ashe: switched up $total and $offset as per MySQL manual + // Note for other DBALs: if $total == -1 we only want to set an offset (no pun intended) + function sql_query_limit($query, $total, $offset = 0, $expire_time = 0) + { + if ($query != '') + { + $this->query_result = false; + $this->num_queries++; - $query .= ' LIMIT ' . ((!empty($offset)) ? $total . ', ' . $offset : $total); + $query .= ' LIMIT ' . ((!empty($offset)) ? "$offset, $total" : $total); - return $this->sql_query($query, $expire_time); - } - else - { - return false; - } + return $this->sql_query($query, $expire_time); + } + else + { + return false; + } } // Idea for this from Ikonboard diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 0984498974..cf04a62f1a 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -447,10 +447,7 @@ $sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_karma, u AND u.user_id = p.poster_id ORDER BY $sort_order"; -// 20030226 Ashe: $start first? $offset first? current mysql.php file says that it should be the number of rows -//$result = $db->sql_query_limit($sql, intval($config['posts_per_page']), $start); -$result = $db->sql_query_limit($sql, intval($start), intval($config['posts_per_page'])); - +$result = $db->sql_query_limit($sql, intval($config['posts_per_page']), $start); if ($row = $db->sql_fetchrow($result)) {