mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-18 18:51:12 +01:00
98690ee326
Summary: Depends on D19785. Ref T13217. This converts many of the most common clause construction pathways to the new %Q / %LQ / %LO / %LA / %LJ semantics. Test Plan: Browsed around a bunch, saw fewer warnings and no obvious behavioral errors. The transformations here are generally mechanical (although I did them by hand). Reviewers: amckinley Reviewed By: amckinley Subscribers: hach-que Maniphest Tasks: T13217 Differential Revision: https://secure.phabricator.com/D19789
51 lines
1.2 KiB
PHP
51 lines
1.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* A query class which uses offset/limit paging. Provides logic and accessors
|
|
* for offsets and limits.
|
|
*/
|
|
abstract class PhabricatorOffsetPagedQuery extends PhabricatorQuery {
|
|
|
|
private $offset;
|
|
private $limit;
|
|
|
|
final public function setOffset($offset) {
|
|
$this->offset = $offset;
|
|
return $this;
|
|
}
|
|
|
|
final public function setLimit($limit) {
|
|
$this->limit = $limit;
|
|
return $this;
|
|
}
|
|
|
|
final public function getOffset() {
|
|
return $this->offset;
|
|
}
|
|
|
|
final public function getLimit() {
|
|
return $this->limit;
|
|
}
|
|
|
|
protected function buildLimitClause(AphrontDatabaseConnection $conn) {
|
|
if ($this->limit && $this->offset) {
|
|
return qsprintf($conn, 'LIMIT %d, %d', $this->offset, $this->limit);
|
|
} else if ($this->limit) {
|
|
return qsprintf($conn, 'LIMIT %d', $this->limit);
|
|
} else if ($this->offset) {
|
|
return qsprintf($conn, 'LIMIT %d, %d', $this->offset, PHP_INT_MAX);
|
|
} else {
|
|
return qsprintf($conn, '');
|
|
}
|
|
}
|
|
|
|
final public function executeWithOffsetPager(PHUIPagerView $pager) {
|
|
$this->setLimit($pager->getPageSize() + 1);
|
|
$this->setOffset($pager->getOffset());
|
|
|
|
$results = $this->execute();
|
|
|
|
return $pager->sliceResults($results);
|
|
}
|
|
|
|
}
|