Limits and offsets

Learn about limits and offsets

Limiting the number of results returned by a query, is achieved by using the limit method.

$result = $db->from('users')
             ->orderBy('name')
             ->limit(25)
             ->select()
             ->all();
SELECT * FROM `users` ORDER BY `name` ASC LIMIT 25

You can skip a certain number of records by using the offset method. The skipped records will not be added to the results set. This method can be used only in conjunction with the limit method.

$result = $db->from('users')
             ->orderBy('name')
             ->limit(25)
             ->offset(10)
             ->select()
             ->all();
SELECT * FROM `users` ORDER BY `name` ASC LIMIT 25 OFFSET 10