CodeIgniter Forums
SQL Server 2012 (11.0.*) OFFSET NOT supported on mssql_driver LIMIT - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: Issues (https://forum.codeigniter.com/forumdisplay.php?fid=19)
+--- Thread: SQL Server 2012 (11.0.*) OFFSET NOT supported on mssql_driver LIMIT (/showthread.php?tid=69827)



SQL Server 2012 (11.0.*) OFFSET NOT supported on mssql_driver LIMIT - FlavioSuar - 01-22-2018

Hi,

My first post on this forum!
I'm using CI + FlexiGrid + MySQL for a web app. This works very well.
Now I'm converting it to use MS SQL Server 2012 and the pagination don't works anymore...
After several tests I found the problem:

On the sqlsrv_driver.php file, on the _limit() method, the code starts this way:
PHP Code:
    protected function _limit($sql)

    {

        
// 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';
        } 


But on the mssql_driver.php file this piece of code don't exists.
After I copyed the piece of code to this file, my web app worked again!

This is a bug or a feature?
I'm on CI 3.1.4, but the files are the same on CI 3.1.7...

Just my 0.02...
Thank you for any advice!


RE: SQL Server 2012 (11.0.*) OFFSET NOT supported on mssql_driver LIMIT - Narf - 01-26-2018

The mssql driver is deprecated; use sqlsrv.


RE: SQL Server 2012 (11.0.*) OFFSET NOT supported on mssql_driver LIMIT - FlavioSuar - 01-29-2018

Thx for reply!
I'm trying to access MS SQL from Linux, using PHP 5.6. But I didn't find the sqlsrv driver for PHP 5.6
Any advice?

TIA!


RE: SQL Server 2012 (11.0.*) OFFSET NOT supported on mssql_driver LIMIT - Narf - 01-29-2018

My advice is to upgrade PHP ... Even 7.0 is already in security maintenance mode.


RE: SQL Server 2012 (11.0.*) OFFSET NOT supported on mssql_driver LIMIT - FlavioSuar - 01-29-2018

OK, thx!!