-
Notifications
You must be signed in to change notification settings - Fork 0
offset
Corey Avis edited this page Sep 23, 2026
·
2 revisions
Applies a standalone offset to a SELECT query. This method specifies the number of rows to skip before starting to return data.
While you can provide an offset directly within the
limit()method, usingoffset()allows you to decouple limit and offset logic dynamically in your application.📌 Note that an offset requires a limit to be set on the query to compile successfully.
offset(int $offset = 0): static
offset (interger) : The number of rows to skip before starting to return rows. Must be a positive integer.
If the offset number is a negative number than it will be ignored.
(static) : Returns the current instance to allow for method chaining.
$db->select()->order('id')->limit(10)->offset(20)->execute();
// Result: SELECT * FROM `table` ORDER BY `id` LIMIT 10 OFFSET 20
- Logs a notice if offset is not a positive integer.
- Logs a notice if an offset is defined without a corresponding
limit(). - Triggers a warning if applied to an
UPDATEorDELETEstatement during compilation. - Throws an exception if
limit()is used without an explicitorder()clause.