summaryrefslogtreecommitdiffstats
path: root/system/database/drivers/pdo
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2014-11-18 10:12:35 +0100
committerAndrey Andreev <narf@devilix.net>2014-11-18 10:12:35 +0100
commited3fc511e4e5aa7b171fd806e73401ace2497b32 (patch)
tree7be44673224139a6bf4dba41f18fbfb7378a1dba /system/database/drivers/pdo
parent71f0099cf443eaa98e2510b3fc274da4715b3b36 (diff)
Force ORDER BY usage with OFFSET-FETCH on SQL Server
Close #3128 Close #3332 Close #3334 Close #3335
Diffstat (limited to 'system/database/drivers/pdo')
-rw-r--r--system/database/drivers/pdo/subdrivers/pdo_sqlsrv_driver.php3
1 files changed, 3 insertions, 0 deletions
diff --git a/system/database/drivers/pdo/subdrivers/pdo_sqlsrv_driver.php b/system/database/drivers/pdo/subdrivers/pdo_sqlsrv_driver.php
index 78591755a..42627139b 100644
--- a/system/database/drivers/pdo/subdrivers/pdo_sqlsrv_driver.php
+++ b/system/database/drivers/pdo/subdrivers/pdo_sqlsrv_driver.php
@@ -304,6 +304,9 @@ class CI_DB_pdo_sqlsrv_driver extends CI_DB_pdo_driver {
// As of SQL Server 2012 (11.0.*) OFFSET is supported
if (version_compare($this->version(), '11', '>='))
{
+ // SQL Server 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';
}