Preparations for Oracle database abstraction update.

Replaced a few hardcoded LIMIT clauses with database function.
Wrapped UNION statement in SpecialRecentchangeslinked for Oracle compatibility.
This commit is contained in:
Jure Kajzer 2009-05-11 12:38:45 +00:00
parent 1caee6915b
commit 45758df495
3 changed files with 8 additions and 5 deletions

View file

@ -707,8 +707,8 @@ class Article {
GROUP BY rev_user, rev_user_text, user_real_name
ORDER BY timestamp DESC";
if($limit > 0) { $sql .= ' LIMIT '.$limit; }
if($offset > 0) { $sql .= ' OFFSET '.$offset; }
if($limit > 0)
$sql = $dbr->limitResult($sql, $limit, $offset);
$sql .= ' '. $this->getSelectOptions();

View file

@ -40,7 +40,8 @@ function wfSpecialNewimages( $par, $specialPage ) {
if ($hidebotsql) {
$sql .= "$hidebotsql WHERE ug_group IS NULL";
}
$sql .= ' ORDER BY img_timestamp DESC LIMIT 1';
$sql .= ' ORDER BY img_timestamp DESC';
$sql = $dbr->limitResult($sql, 1, false);
$res = $dbr->query( $sql, __FUNCTION__ );
$row = $dbr->fetchRow( $res );
if( $row !== false ) {
@ -93,7 +94,7 @@ function wfSpecialNewimages( $par, $specialPage ) {
$sql .= ' WHERE ' . $dbr->makeList( $where, LIST_AND );
}
$sql.=' ORDER BY img_timestamp '. ( $invertSort ? '' : ' DESC' );
$sql.=' LIMIT ' . ( $limit + 1 );
$sql = $dbr->limitResult($sql, ( $limit + 1 ), false);
$res = $dbr->query( $sql, __FUNCTION__ );
/**

View file

@ -155,7 +155,9 @@ class SpecialRecentchangeslinked extends SpecialRecentchanges {
$sql = $subsql[0];
else {
// need to resort and relimit after union
$sql = "(" . implode( ") UNION (", $subsql ) . ") ORDER BY rc_timestamp DESC LIMIT {$limit}";
// unwrapped UNION block will not work in Oracle. Wrapper aded.
$sql = "SELECT * FROM ((" . implode( ") UNION (", $subsql ) . ")) ORDER BY rc_timestamp DESC";
$sql = $dbr->limitResult($sql, $limit, false);
}
$res = $dbr->query( $sql, __METHOD__ );