Replying to myself with some additional findings:

The limit method from the Mssql.php Pdo Adapter seems to have the right
logic, but to work it requires the first parameter ($sql), as it will
rewrite the query to make it work with MSSQL.

But method _renderLimitoffset from Select.php calls the limit method passing
an empty first parameter: trim($this->_adapter->limit('', $count, $offset))
... thus breaking the result returned by Mssql.php.

One (not optimal) workaround I have found it this:

$eventLogs = new EventLogs();
$select = $eventLogs->select();
$select->order('eventlog_timestamp DESC');

$sql = $select->__toString();
$sql = $eventLogs->getAdapter()->limit($sql, 20, 10);

And then you use $sql for your fetchAll.


Antonio






JARUZ wrote:
> 
> Hi,
> 
> I have a very simple EventLogs extends Zend_Db_Table_Abstract class. It
> works fine except when I want to LIMIT the results on MSSQL:
> 
> $eventLogs = new EventLogs();
> $select = $eventLogs->select();
> $select->order('eventlog_timestamp DESC');
> $select->limit(20, 10);
> 
> when I echo $select it shows:
> 
> SELECT "logs_event".* FROM "logs_event" ORDER BY "eventlog_timestamp" DESC
> SELECT * FROM (SELECT TOP 10 * FROM () AS inner_tbl) AS outer_tbl
> 
> That of course results in an Incorrect Syntax error from the MSSQL server.
> 
> If I remove $select->limit(20, 10); the query works just fine.
> 
> 
> Antonio
> 

-- 
View this message in context: 
http://www.nabble.com/Zend-Db-Select-limit-broken-for-MSSQL--tp15799936s16154p15799946.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to