Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Pagination with offset and limit

Hello everyone, I just start with Phalcon framework, passed trough documantacion and I like it so far... I have one fast question. Im building and api with phalcon and im stuck on part where I have to build pagination for pages. I have to make it with offset and limit parms. So GET /pages?limit=100&offset=100 would give the result set 101 - 200

So, should i make Controller method for pagination and use one of Phalcon ways with Adapter Model or Query Builder or there is a bether way .. btw im outputing json with transformer (dosent have views).

If I understand your question better use LIMIT in SQL. Because paginator of Phalcon did not know how to add LIMIT to the SQL query - it has been working with resulset of SQL query. It's not fast for many rows.

edited Oct '15

Go for Query Builder since will only get what you need. Adapter Model will get all data at once and query through it


Thanks both on advice. I did it with Query Builder.