Changeset View
Changeset View
Standalone View
Standalone View
src/applications/pholio/query/PholioImageQuery.php
Show All 38 Lines | final class PholioImageQuery | ||||
public function setMockCache($mock_cache) { | public function setMockCache($mock_cache) { | ||||
$this->mockCache = $mock_cache; | $this->mockCache = $mock_cache; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getMockCache() { | public function getMockCache() { | ||||
return $this->mockCache; | return $this->mockCache; | ||||
} | } | ||||
protected function loadPage() { | public function newResultObject() { | ||||
$table = new PholioImage(); | return new PholioImage(); | ||||
$conn_r = $table->establishConnection('r'); | |||||
$data = queryfx_all( | |||||
$conn_r, | |||||
'SELECT * FROM %T %Q %Q %Q', | |||||
$table->getTableName(), | |||||
$this->buildWhereClause($conn_r), | |||||
$this->buildOrderClause($conn_r), | |||||
$this->buildLimitClause($conn_r)); | |||||
$images = $table->loadAllFromArray($data); | |||||
return $images; | |||||
} | } | ||||
protected function buildWhereClause(AphrontDatabaseConnection $conn) { | protected function loadPage() { | ||||
$where = array(); | return $this->loadStandardPage($this->newResultObject()); | ||||
} | |||||
$where[] = $this->buildPagingClause($conn); | protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { | ||||
$where = parent::buildWhereClauseParts($conn); | |||||
if ($this->ids) { | if ($this->ids !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn, | $conn, | ||||
'id IN (%Ld)', | 'id IN (%Ld)', | ||||
$this->ids); | $this->ids); | ||||
} | } | ||||
if ($this->phids) { | if ($this->phids !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn, | $conn, | ||||
'phid IN (%Ls)', | 'phid IN (%Ls)', | ||||
$this->phids); | $this->phids); | ||||
} | } | ||||
if ($this->mockIDs) { | if ($this->mockIDs !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn, | $conn, | ||||
'mockID IN (%Ld)', | 'mockID IN (%Ld)', | ||||
$this->mockIDs); | $this->mockIDs); | ||||
} | } | ||||
if ($this->obsolete !== null) { | if ($this->obsolete !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn, | $conn, | ||||
'isObsolete = %d', | 'isObsolete = %d', | ||||
$this->obsolete); | $this->obsolete); | ||||
} | } | ||||
return $this->formatWhereClause($conn, $where); | return $where; | ||||
} | } | ||||
protected function willFilterPage(array $images) { | protected function willFilterPage(array $images) { | ||||
assert_instances_of($images, 'PholioImage'); | assert_instances_of($images, 'PholioImage'); | ||||
if ($this->getMockCache()) { | if ($this->getMockCache()) { | ||||
$mocks = $this->getMockCache(); | $mocks = $this->getMockCache(); | ||||
} else { | } else { | ||||
▲ Show 20 Lines • Show All 63 Lines • Show Last 20 Lines |