LogoLogo
9.3.0
9.3.0
  • Introduction
  • What's New?
  • Installation & Usage
  • Migration Guide
  • Contributing & Filing Issues
  • Query Builder
    • Getting a New Query
    • Building Queries
      • Selects
      • From
      • Joins
      • Wheres
      • Order By
      • Group By and Having
      • Limit, Offset, and Pagination
      • Locks
      • Unions
      • Common Table Expressions (i.e. CTEs)
      • Raw Expressions
      • When / Conditionals
      • Query Parameters and Bindings
    • Executing Queries
      • Retrieving Results
      • Aggregates
      • Inserts, Updates, and Deletes
    • Options and Utilities
      • Query Options and Utilities
      • Clone and Reset
      • Return Format
      • Column Formatter
      • Interception Points
    • Debugging
      • sqlCommenter
  • Schema Builder
    • Overview
    • Create
    • Columns
    • Column Modifiers
    • Column Constraints
    • Creating Table Constraints
    • Alter
    • Drop
    • Debugging
  • External Links
    • API Docs
    • Source Code
    • Issue Tracker
Powered by GitBook
On this page
  • limit
  • take
  • offset
  • forPage
  • simplePaginate & paginate

Was this helpful?

Edit on GitHub
Export as PDF
  1. Query Builder
  2. Building Queries

Limit, Offset, and Pagination

PreviousGroup By and HavingNextLocks

Was this helpful?

limit

Name

Type

Required

Default

Description

value

numeric

true

The limit value for the query.

Sets the limit value for the query.

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

take

Name

Type

Required

Default

Description

value

numeric

true

The limit value for the query.

Sets the limit value for the query. Alias for .

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

offset

Name

Type

Required

Default

Description

value

numeric

true

The offset value for the query.

Sets the offset value for the query.

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

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
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 section of the documentation.

limit
Retreiving Results