diff options
author | Andrey Andreev <narf@bofh.bg> | 2012-06-08 15:35:40 +0200 |
---|---|---|
committer | Andrey Andreev <narf@bofh.bg> | 2012-06-08 15:35:40 +0200 |
commit | ad5604e8a8fff6fb36179e9e165b9e5a717dc508 (patch) | |
tree | 99c4ba0ccfa7653ef5752dbcdae35d47f5cdca23 /system/database/drivers/sqlsrv/sqlsrv_driver.php | |
parent | d25c589dc3bbfc83fb59bbeb1a3046b99bf694f8 (diff) |
Update OFFSET implementation for SQL Server 2012
Diffstat (limited to 'system/database/drivers/sqlsrv/sqlsrv_driver.php')
-rw-r--r-- | system/database/drivers/sqlsrv/sqlsrv_driver.php | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php index e3e97f14b..655a9e90b 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_driver.php +++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php @@ -463,12 +463,9 @@ class CI_DB_sqlsrv_driver extends CI_DB { protected function _limit($sql, $limit, $offset) { // As of SQL Server 2012 (11.0.*) OFFSET is supported - if ($offset != 0 && version_compare($this->version(), '11', '>=')) - { - return $sql .= ' OFFSET '. (int) $offset .' ROW FETCH NEXT '. (int) $limit .' ROW ONLY'; - } - - return preg_replace('/(^\SELECT (DISTINCT)?)/i','\\1 TOP '.($limit + $offset).' ', $sql); + return version_compare($this->version(), '11', '>=') + ? $sql.' OFFSET '.(int) $offset.' ROWS FETCH NEXT '.(int) $limit.' ROWS ONLY' + : preg_replace('/(^\SELECT (DISTINCT)?)/i','\\1 TOP '.($limit + $offset).' ', $sql); } // -------------------------------------------------------------------- |