summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2016-01-06 14:53:19 +0100
committerAndrey Andreev <narf@devilix.net>2016-01-06 14:53:19 +0100
commite8de9eb4a8bba7cde0d81fe8571bcceed7aef77b (patch)
tree48d91c924f0889bbcf1da92f5de228f522deb58a
parent0ca9ae6ca109177eb0e80456b097a9d63412517e (diff)
[ci skip] Add support for OFFSET with Oracle 12c
As requested in #4279
-rw-r--r--system/database/drivers/oci8/oci8_driver.php8
1 files changed, 8 insertions, 0 deletions
diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php
index 206924d06..994f8f33a 100644
--- a/system/database/drivers/oci8/oci8_driver.php
+++ b/system/database/drivers/oci8/oci8_driver.php
@@ -654,6 +654,14 @@ class CI_DB_oci8_driver extends CI_DB {
*/
protected function _limit($sql)
{
+ if (version_compare($this->version(), '12.1', '>='))
+ {
+ // OFFSET-FETCH can be used only with the ORDER BY clause
+ empty($this->qb_orderby) && $sql .= ' ORDER BY 1';
+
+ return $sql.' OFFSET '.(int) $this->qb_offset.' ROWS FETCH NEXT '.$this->qb_limit.' ROWS ONLY';
+ }
+
$this->limit_used = TRUE;
return 'SELECT * FROM (SELECT inner_query.*, rownum rnum FROM ('.$sql.') inner_query WHERE rownum < '.($this->qb_offset + $this->qb_limit + 1).')'
.($this->qb_offset ? ' WHERE rnum >= '.($this->qb_offset + 1) : '');