Skip to content

Commit

Permalink
Fix limiting queries.
Browse files Browse the repository at this point in the history
  • Loading branch information
yunosh committed Jan 22, 2014
1 parent fd67d63 commit 653039d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion framework/Db/lib/Horde/Db/Adapter/Oci8.php
Expand Up @@ -376,7 +376,12 @@ public function addLimitOffset($sql, $options)
if (isset($options['limit'])) {
$offset = isset($options['offset']) ? $options['offset'] : 0;
$limit = $options['limit'] + $offset;
$sql = "SELECT * FROM ($sql) WHERE ROWNUM <= $limit AND ROWNUM > $offset";
if ($limit) {
$sql = "SELECT a.*, ROWNUM rnum FROM ($sql) a WHERE ROWNUM <= $limit";
if ($offset) {
$sql = "SELECT * FROM ($sql) WHERE rnum > $offset";
}
}
}
return $sql;
}
Expand Down

0 comments on commit 653039d

Please sign in to comment.