View Single Post
  #3 (permalink)  
Old 05-23-2008, 03:08 AM
neriodavid neriodavid is offline
Junior Member
 
Join Date: May 2008
Posts: 5
Default

Quote:
Originally Posted by jasonw View Post
This is how MySQL (since 3.23, I believe), will allow you to do LIMIT clauses (:

Code:
[LIMIT {[offset,] row_count | row_count OFFSET offset}]
That is, how you do it in a raw SQL query.
The cause of your confusion comes from the fact you are using Zend_Db_Select`s limit() method, which takes it`s arguments as ->limit($count, $offset).

So, technically both are correct. The latter being correct for ACTUAL SQL, and the former correct for Db_Select objects.

However, I HIGHLY recommend, if you are using Zend_Db_Select objects to build your queries, using the built in limitPage() method.

Its use is simple:
limitPage($pageNumber, $pageLength)

This saves you having to calculate your offset beforehand.
Thanks very much. I just thought in the Manual on Zend_Db_Select's limit() method, the example's comment code seem say it is uses [LIMIT {row_count, [offset] | row_count OFFSET offset}]. I knew the format: LIMIT row_count OFFSET offset will always right in ACTUAL SQL.
Reply With Quote