| Total Complexity | 7 |
| Total Lines | 54 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | class DatabasePagination extends Pagination implements |
||
| 15 | DatabaseExpressionInterface |
||
| 16 | { |
||
| 17 | /** |
||
| 18 | * Converts the pagination into a SQL expression for the LIMIT clause. |
||
| 19 | * |
||
| 20 | * @return string A SQL string fragment. |
||
| 21 | */ |
||
| 22 | public function sql() |
||
| 23 | { |
||
| 24 | if ($this->active() && $this->hasLimit()) { |
||
| 25 | $limit = $this->limit(); |
||
| 26 | $offset = $this->offset(); |
||
| 27 | return 'LIMIT '.$offset.', '.$limit; |
||
| 28 | } |
||
| 29 | |||
| 30 | return ''; |
||
| 31 | } |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Determine if the expression has a number per page. |
||
| 35 | * |
||
| 36 | * @return boolean |
||
| 37 | */ |
||
| 38 | public function hasLimit() |
||
| 39 | { |
||
| 40 | return ($this->limit() > 0); |
||
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * Alias of {@see self::numPerPage()} |
||
| 45 | * |
||
| 46 | * @return integer |
||
| 47 | */ |
||
| 48 | public function limit() |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Retrieve the offset from the page number and count. |
||
| 55 | * |
||
| 56 | * @return integer |
||
| 57 | */ |
||
| 58 | public function offset() |
||
| 68 | } |
||
| 69 | } |
||
| 70 |