ZF-8947: Zend DB Select Limit Not Executing Properly


If you specify a DB table then use select statement with an order and limit clause, the output for the limit range is wrong.

$nUserId = 123; $select = $this->_table->select(); $select->where('user_id = ?', $nUserId) ->order('createddate DESC') ->limit(0, 200);

print $select;

// SELECT myRecords.* FROM myRecords WHERE (user_id = '123') // ORDER BY createddate DESC LIMIT 2147483647 OFFSET 2

The limit is supposed to be 0 not 2147483647

Regards, Cliburn M. Solano


I just ran into this bug too, in my quick test, order does not seem to matter. It seems to be related to building a query off of Zend_Db_Table though. I am using zf 1.11.11.

It also only occurs if the first argument is 0. Set the argument to 1 and it behaves as expected.

Maybe i should reread the documentation first. The argument order is opposite of what is expected in mysql. This is not a bug.