This specific comment, unfortunately, confuses the two common ways of considering pagination or grouping in queries. The SELECT syntax, as Andrew describes, allows the OFFSET parameter , the number of items to skip before returning anything. However, it is most often used with pagination, as in the pagination library from which your quote was made. In this case, it is more useful to request a specific page number.
To compare these two options, consider the case when you performed a search and went to page 3, with 10 points per page. Elements 1-20 were on the first two pages; therefore, the OFFSET parameter will be 20:
SELECT * FROM table WHERE searched LIMIT 10 OFFSET 20
or
SELECT * FROM table WHERE searched LIMIT 20,10
Unfortunately, the parameter $page_no in the above example probably wants to be 3, the page number. In this case, it will be necessary to calculate the SQL offset. Given that get_items does not seem to be a standard model method, it is probably calculated there; alternatively, the pagination library seems to have the sql_offset property, which is likely to compute it for you. In any case, the calculation is quite simple:
$offset = max($page_no - 1, 0) * $limit;
eswald
source share