| 1 | <?php |
||
| 10 | trait Range |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @var int|null |
||
| 14 | */ |
||
| 15 | protected $limit; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @var int|null |
||
| 19 | */ |
||
| 20 | protected $offset; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @param int $limit max. number of records |
||
| 24 | * @param int|null $offset base-0 record number offset |
||
| 25 | * |
||
| 26 | * @return $this |
||
| 27 | * |
||
| 28 | * @throws InvalidArgumentException if the given limit is less than 1, or if the given offset if less than 0 |
||
| 29 | */ |
||
| 30 | 1 | public function limit($limit, $offset = null) |
|
| 45 | |||
| 46 | /** |
||
| 47 | * @param int $page_num base-1 page number |
||
| 48 | * @param int $page_size number of records per page |
||
| 49 | * |
||
| 50 | * @return $this |
||
| 51 | * |
||
| 52 | * @throws InvalidArgumentException if the given page number or page size are less than 1 |
||
| 53 | */ |
||
| 54 | 1 | public function page($page_num, $page_size) |
|
| 66 | |||
| 67 | /** |
||
| 68 | * @return string the LIMIT/OFFSET clause (or an empty string, if no limit has been set) |
||
| 69 | */ |
||
| 70 | protected function buildLimit() |
||
| 76 | } |
||
| 77 |