Switched up $total and $offset as per MySQL manual

git-svn-id: file:///svn/phpbb/trunk@3606 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Ludovic Arnaud 2003-03-06 02:36:04 +00:00
parent 04e9ebb824
commit 4e503c0508
2 changed files with 16 additions and 17 deletions

View file

@ -209,21 +209,23 @@ class sql_db
return ($this->query_result) ? $this->query_result : false; return ($this->query_result) ? $this->query_result : false;
} }
function sql_query_limit($query, $total, $offset = 0, $expire_time = 0) // 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)
if ($query != '') function sql_query_limit($query, $total, $offset = 0, $expire_time = 0)
{ {
$this->query_result = false; if ($query != '')
$this->num_queries++; {
$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); return $this->sql_query($query, $expire_time);
} }
else else
{ {
return false; return false;
} }
} }
// Idea for this from Ikonboard // Idea for this from Ikonboard

View file

@ -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 AND u.user_id = p.poster_id
ORDER BY $sort_order"; 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($config['posts_per_page']), $start);
$result = $db->sql_query_limit($sql, intval($start), intval($config['posts_per_page']));
if ($row = $db->sql_fetchrow($result)) if ($row = $db->sql_fetchrow($result))
{ {