diff options
author | Andrey Andreev <narf@devilix.net> | 2016-01-07 13:22:00 +0100 |
---|---|---|
committer | Andrey Andreev <narf@devilix.net> | 2016-01-07 13:22:00 +0100 |
commit | 868b194fe50c0544b43cf8be523c39bdea18897d (patch) | |
tree | 0a7431454537634337347a127df4df89d97d714f /system/database/drivers | |
parent | 1fbeb61596e0f781999dbb48c95ef3c1e3260e48 (diff) |
[ci skip] Add Oracle 12.1 OFFSET support to PDO_OCI as well
Reference: #4279
Diffstat (limited to 'system/database/drivers')
-rw-r--r-- | system/database/drivers/pdo/subdrivers/pdo_oci_driver.php | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/system/database/drivers/pdo/subdrivers/pdo_oci_driver.php b/system/database/drivers/pdo/subdrivers/pdo_oci_driver.php index 4791ab157..d4cfb7dd7 100644 --- a/system/database/drivers/pdo/subdrivers/pdo_oci_driver.php +++ b/system/database/drivers/pdo/subdrivers/pdo_oci_driver.php @@ -311,6 +311,14 @@ class CI_DB_pdo_oci_driver extends CI_DB_pdo_driver { */ 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'; + } + 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): ''); } |