Limit and offset
April 22, 2024 ยท View on GitHub
The \Yiisoft\Db\Query\Query::limit() and \Yiisoft\Db\Query\Query::offset() methods specify
the LIMIT and OFFSET fragments of a SQL query.
For example, the following code will build a query that will return only 10 records starting from the 20th one.
$query->limit(10)->offset(20);
The relevant part of SQL is:
LIMIT 10 OFFSET 20
The query ignores invalid limit or offset such as a negative value.
Note: For DBMS that don't support
LIMITandOFFSETsuch asMSSQL, query builder will generate a SQL statement that emulates this behavior.