Search…
Limit, Offset, and Pagination

limit

Name
Type
Required
Default
Description
value
numeric
true
The limit value for the query.
Sets the limit value for the query.
QueryBuilder
1
query.from( "users" )
2
.limit( 5 );
Copied!
MySQL
1
SELECT *
2
FROM `users`
3
LIMIT 5
Copied!

take

Name
Type
Required
Default
Description
value
numeric
true
The limit value for the query.
Sets the limit value for the query. Alias for limit.
QueryBuilder
1
query.from( "users" )
2
.take( 5 );
Copied!
MySQL
1
SELECT *
2
FROM `users`
3
LIMIT 5
Copied!

offset

Name
Type
Required
Default
Description
value
numeric
true
The offset value for the query.
Sets the offset value for the query.
QueryBuilder
1
query.from( "users" )
2
.offset( 25 );
Copied!
MySQL
1
SELECT *
2
FROM `users`
3
OFFSET 25
Copied!

forPage

Name
Type
Required
Default
Description
page
numeric
true
The page number to retrieve.
maxRows
numeric
true
The number of records per page. If a number less than 0 is passed, 0 is used instead.
Helper method to calculate the limit and offset given a page number and count per page.
QueryBuilder
1
query.from( "users" )
2
.forPage( 3, 15 );
Copied!
MySQL
1
SELECT *
2
FROM `users`
3
LIMIT 15
4
OFFSET 30
Copied!

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.