Changeset View
Changeset View
Standalone View
Standalone View
src/applications/paste/query/PhabricatorPasteQuery.php
Show First 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | public function withDateCreatedAfter($date_created_after) { | ||||
return $this; | return $this; | ||||
} | } | ||||
protected function newResultObject() { | protected function newResultObject() { | ||||
return new PhabricatorPaste(); | return new PhabricatorPaste(); | ||||
} | } | ||||
protected function loadPage() { | protected function loadPage() { | ||||
$table = new PhabricatorPaste(); | return $this->loadStandardPage(new PhabricatorPaste()); | ||||
$conn_r = $table->establishConnection('r'); | |||||
$data = queryfx_all( | |||||
$conn_r, | |||||
'SELECT paste.* FROM %T paste %Q %Q %Q', | |||||
$table->getTableName(), | |||||
$this->buildWhereClause($conn_r), | |||||
$this->buildOrderClause($conn_r), | |||||
$this->buildLimitClause($conn_r)); | |||||
$pastes = $table->loadAllFromArray($data); | |||||
return $pastes; | |||||
} | } | ||||
protected function didFilterPage(array $pastes) { | protected function didFilterPage(array $pastes) { | ||||
if ($this->needRawContent) { | if ($this->needRawContent) { | ||||
$pastes = $this->loadRawContent($pastes); | $pastes = $this->loadRawContent($pastes); | ||||
} | } | ||||
if ($this->needContent) { | if ($this->needContent) { | ||||
$pastes = $this->loadContent($pastes); | $pastes = $this->loadContent($pastes); | ||||
} | } | ||||
return $pastes; | return $pastes; | ||||
} | } | ||||
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { | protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { | ||||
$where = parent::buildWhereClauseParts($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->authorPHIDs) { | if ($this->authorPHIDs !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn, | $conn, | ||||
'authorPHID IN (%Ls)', | 'authorPHID IN (%Ls)', | ||||
$this->authorPHIDs); | $this->authorPHIDs); | ||||
} | } | ||||
if ($this->parentPHIDs) { | if ($this->parentPHIDs !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn, | $conn, | ||||
'parentPHID IN (%Ls)', | 'parentPHID IN (%Ls)', | ||||
$this->parentPHIDs); | $this->parentPHIDs); | ||||
} | } | ||||
if ($this->languages) { | if ($this->languages !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn, | $conn, | ||||
'language IN (%Ls)', | 'language IN (%Ls)', | ||||
$this->languages); | $this->languages); | ||||
} | } | ||||
if ($this->dateCreatedAfter) { | if ($this->dateCreatedAfter !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn, | $conn, | ||||
'dateCreated >= %d', | 'dateCreated >= %d', | ||||
$this->dateCreatedAfter); | $this->dateCreatedAfter); | ||||
} | } | ||||
if ($this->dateCreatedBefore) { | if ($this->dateCreatedBefore !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn, | $conn, | ||||
'dateCreated <= %d', | 'dateCreated <= %d', | ||||
$this->dateCreatedBefore); | $this->dateCreatedBefore); | ||||
} | } | ||||
return $where; | return $where; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 115 Lines • Show Last 20 Lines |