- ⌂ query
- Methods
query::limit_again()
Updates an existing LIMIT clause to potentially reduce, but not expand, the count. If an offset is specified, it will be added to the existing offset.
To "unset" an existing limit, so there is no limit, use
limit(0)
.Prototype
query limit_again(int $count)
query limit_again(int $offset, int $count)
query limit_again(array $offset_count)
Parameters
The following parameters may be passed in any of the forms listed above.
- count - Restrict the number of results to count items.
- offset - Exclude/skip rows before offset.
- offset_count - array containing [$count] or [$offset, $count].
Return
The updated query object is returned. This is handy for chaining additional methods.
Example
// limit results to the second "page"
$page = 2;
$items_per_page = 10;
$offset = $page * $items_per_page;
$query->limit($offset, $items_per_page);
// reduce the count down from 10 to 5
$query->limit_again(5);
// The following has no effect, because the count
// is greater than the existing count of 5.
$query->limit_again(12);