Limit, Offset, and Pagination

limit

Sets the limit value for the query.

QueryBuilder
query.from( "users" )
    .limit( 5 );
MySQL
SELECT *
FROM `users`
LIMIT 5

take

Sets the limit value for the query. Alias for limit.

QueryBuilder
query.from( "users" )
    .take( 5 );
MySQL
SELECT *
FROM `users`
LIMIT 5

offset

Sets the offset value for the query.

QueryBuilder
query.from( "users" )
    .offset( 25 );
MySQL
SELECT *
FROM `users`
OFFSET 25

forPage

Helper method to calculate the limit and offset given a page number and count per page.

QueryBuilder
query.from( "users" )
    .forPage( 3, 15 );
MySQL
SELECT *
FROM `users`
LIMIT 15
OFFSET 30

simplePaginate & paginate

This method combines forPage, count, and get to create a pagination struct alongside the results. Information on the simplePaginate or paginate methods, including custom pagination collectors, can be found in the Retreiving Results section of the documentation.