ZF-8947: Zend DB Select Limit Not Executing Properly
Description
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
Comments
Posted by Dan Johansson (datasage) on 2011-12-30T20:33:33.000+0000
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.
Posted by Dan Johansson (datasage) on 2011-12-30T20:34:48.000+0000
It also only occurs if the first argument is 0. Set the argument to 1 and it behaves as expected.
Posted by Dan Johansson (datasage) on 2011-12-30T20:37:14.000+0000
Maybe i should reread the documentation first. The argument order is opposite of what is expected in mysql. This is not a bug.