ZF-10831: Distinct statement doesn't work with basic limit in Zend_Db_Adapter_Sqlsrv
I have found an error with basic limit statement if I use Zend_Db_Adapter_Sqlsrv as database adapter. Here is example:
$adapter = Zend_Registry::get('dbAdapter'); // Instance of Zend_Db_Adapter_Sqlsrv $select = $adapter->select(); $select->distinct(); $select->from('Foo', array('FooID')); $select->limit(5); echo $select->__toString();
The result is following:
SELECT TOP 5 DISTINCT "Foo"."FooID" FROM "Foo"
But it produces database error. TOP have to be after DISTINCT.
SELECT DISTINCT TOP 5 "Foo"."FooID" FROM "Foo"
I'm using Zend Framework 1.11.1, Zend Server 5.0.2 (PHP 5.3.2), MSSQL 2005 Express.