Path: blob/master/src/infrastructure/query/PhabricatorOffsetPagedQuery.php
12241 views
<?php12/**3* A query class which uses offset/limit paging. Provides logic and accessors4* for offsets and limits.5*/6abstract class PhabricatorOffsetPagedQuery extends PhabricatorQuery {78private $offset;9private $limit;1011final public function setOffset($offset) {12$this->offset = $offset;13return $this;14}1516final public function setLimit($limit) {17$this->limit = $limit;18return $this;19}2021final public function getOffset() {22return $this->offset;23}2425final public function getLimit() {26return $this->limit;27}2829protected function buildLimitClause(AphrontDatabaseConnection $conn) {30if ($this->limit && $this->offset) {31return qsprintf($conn, 'LIMIT %d, %d', $this->offset, $this->limit);32} else if ($this->limit) {33return qsprintf($conn, 'LIMIT %d', $this->limit);34} else if ($this->offset) {35return qsprintf($conn, 'LIMIT %d, %d', $this->offset, PHP_INT_MAX);36} else {37return qsprintf($conn, '');38}39}4041final public function executeWithOffsetPager(PHUIPagerView $pager) {42$this->setLimit($pager->getPageSize() + 1);43$this->setOffset($pager->getOffset());4445$results = $this->execute();4647return $pager->sliceResults($results);48}4950}515253