From 315d6d6188ae8e6a7015a0d31fb3d2652fcce37b Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Tue, 9 Aug 2005 10:30:20 +0000 Subject: [PATCH] limitResult() use 3 argument since ORACLE merge --- includes/Database.php | 8 ++++---- includes/DatabasePostgreSQL.php | 4 ++-- includes/QueryPage.php | 10 +++++++--- includes/SearchMySQL.php | 2 +- includes/SpecialLog.php | 2 +- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/includes/Database.php b/includes/Database.php index 3776e0d4c8..6422057962 100644 --- a/includes/Database.php +++ b/includes/Database.php @@ -1278,11 +1278,11 @@ class Database { * Construct a LIMIT query with optional offset * This is used for query pages */ - function limitResult($sql, $limit, $offset) { - return "$sql LIMIT ".((is_numeric($offset) && $offset != 0)?"{$offset},":"")."{$limit} "; + function limitResult($limit, $offset=false) { + return " LIMIT ".((is_numeric($offset) && $offset != 0)?"{$offset},":"")."{$limit} "; } - function limitResultForUpdate($sql, $num) { - return $this->limitResult($sql, $num, 0); + function limitResultForUpdate($num) { + return $this->limitResult($num, 0); } /** diff --git a/includes/DatabasePostgreSQL.php b/includes/DatabasePostgreSQL.php index c92a824648..7d32166c24 100644 --- a/includes/DatabasePostgreSQL.php +++ b/includes/DatabasePostgreSQL.php @@ -372,8 +372,8 @@ class DatabasePgsql extends Database { return ''; } - function limitResult($limit,$offset) { - return " LIMIT $limit ".(is_numeric($offset)?" OFFSET {$offset} ":""); + function limitResult($sql, $limit,$offset) { + return "$sql LIMIT $limit ".(is_numeric($offset)?" OFFSET {$offset} ":""); } /** diff --git a/includes/QueryPage.php b/includes/QueryPage.php index 3d94b6c577..d76b368a29 100644 --- a/includes/QueryPage.php +++ b/includes/QueryPage.php @@ -160,7 +160,9 @@ class QueryPage { # Clear out any old cached data $dbw->delete( 'querycache', array( 'qc_type' => $this->getName() ), $fname ); # Do query - $res = $dbr->query( $this->getSQL() . $this->getOrder() . $dbr->limitResult( 1000,0 ), $fname ); + $sql = $this->getSQL() . $this->getOrder(); + $sql = $dbr->limitResult($sql, 1000,0); + $res = $dbr->query($sql, $fname); $num = false; if ( $res ) { $num = $dbr->numRows( $res ); @@ -237,7 +239,8 @@ class QueryPage { } } - $sql = $dbr->limitResult($sql . $this->getOrder(), $limit, $offset); + $sql .= $this->getOrder(); + $sql = $dbr->limitResult($sql, $limit, $offset); $res = $dbr->query( $sql ); $num = $dbr->numRows($res); @@ -304,7 +307,8 @@ class QueryPage { $feed->outHeader(); $dbr =& wfGetDB( DB_SLAVE ); - $sql = $this->getSQL() . $this->getOrder().$dbr->limitResult( 50, 0 ); + $sql = $this->getSQL() . $this->getOrder() + $sql = $dbr->limitResult( $sql, 50, 0 ); $res = $dbr->query( $sql, 'QueryPage::doFeed' ); while( $obj = $dbr->fetchObject( $res ) ) { $item = $this->feedResult( $obj ); diff --git a/includes/SearchMySQL.php b/includes/SearchMySQL.php index 52f36e1bc2..310a7b93f0 100644 --- a/includes/SearchMySQL.php +++ b/includes/SearchMySQL.php @@ -86,7 +86,7 @@ class SearchMySQL extends SearchEngine { * @access private */ function queryLimit() { - return $this->db->limitResult('', $this->limit, $this->offset ); + return $this->db->limitResult( '', $this->limit, $this->offset ); } /** diff --git a/includes/SpecialLog.php b/includes/SpecialLog.php index 8e59e933aa..dd09871d20 100644 --- a/includes/SpecialLog.php +++ b/includes/SpecialLog.php @@ -154,7 +154,7 @@ class LogReader { $sql .= " WHERE " . implode( ' AND ', $this->whereClauses ); } $sql .= " ORDER BY log_timestamp DESC "; - $sql = $this->db->limitResult( $sql, $this->limit, $this->offset ); + $sql = $this->db->limitResult($sql, $this->limit, $this->offset ); return $sql; } -- 2.20.1