summaryrefslogtreecommitdiffstats
path: root/system/database/drivers
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-06-08 15:23:01 +0200
committerAndrey Andreev <narf@bofh.bg>2012-06-08 15:23:01 +0200
commitd25c589dc3bbfc83fb59bbeb1a3046b99bf694f8 (patch)
tree648b94fd7e326250b2beaf951f0e6b49aded8628 /system/database/drivers
parent1be495483749c661f785cdef574ac84b2176d43a (diff)
Add OFFSET support for SQL Server 2012
Diffstat (limited to 'system/database/drivers')
-rw-r--r--system/database/drivers/sqlsrv/sqlsrv_driver.php6
1 files changed, 6 insertions, 0 deletions
diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php
index d2b73aee4..e3e97f14b 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_driver.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php
@@ -462,6 +462,12 @@ 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);
}