How can I create OFFSET and FETCH NEXT in Zf2 logic? The result should be like the following
SELECT * FROM mytable
ORDER BY id DESC
OFFSET 100 ROWS
FETCH NEXT 10 ROWS ONLY
as described here. When using the following code
$select = $this->tableGateway->getSql()->select();
$select->order('id DESC');
$select->offset(100);
$select->limit(10);
$resultSet = $this->tableGateway->selectWith($select);
then the output is
SELECT [mytable].*
FROM [mytable]
ORDER BY [id] DESC
LIMIT '10' OFFSET '100'
which does not work for SQL Server. The output I need is the one from above.
The config in db.config.php looks like the following
'db_sql_server' => array(
'driver' => 'pdo',
'dsn' => 'dblib:host=myhost;dbname=mydatabase',
'username' => 'myusername',
'password' => 'mypasswort',
),
I skiped the 'db' config for mysql here. And in global.php
return array(
'service_manager' => array(
'factories' => array(
/**
* Adapter SQL Server
*/
'Application\Db\AdapterSQLServer' => function($sm) {
$config = $sm->get('Config');
return new Adapter($config['db_sql_server']);
},
),
),
)
to which I refere in Module.php with Table Gateway.