Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phortune/query/PhortuneMerchantQuery.php
Show All 22 Lines | public function withMemberPHIDs(array $member_phids) { | ||||
return $this; | return $this; | ||||
} | } | ||||
public function needProfileImage($need) { | public function needProfileImage($need) { | ||||
$this->needProfileImage = $need; | $this->needProfileImage = $need; | ||||
return $this; | return $this; | ||||
} | } | ||||
protected function loadPage() { | public function newResultObject() { | ||||
$table = new PhortuneMerchant(); | return new PhortuneMerchant(); | ||||
$conn = $table->establishConnection('r'); | } | ||||
$rows = queryfx_all( | |||||
$conn, | |||||
'SELECT m.* FROM %T m %Q %Q %Q %Q', | |||||
$table->getTableName(), | |||||
$this->buildJoinClause($conn), | |||||
$this->buildWhereClause($conn), | |||||
$this->buildOrderClause($conn), | |||||
$this->buildLimitClause($conn)); | |||||
return $table->loadAllFromArray($rows); | protected function loadPage() { | ||||
return $this->loadStandardPage($this->newResultObject()); | |||||
} | } | ||||
protected function willFilterPage(array $merchants) { | protected function willFilterPage(array $merchants) { | ||||
$query = id(new PhabricatorEdgeQuery()) | $query = id(new PhabricatorEdgeQuery()) | ||||
->withSourcePHIDs(mpull($merchants, 'getPHID')) | ->withSourcePHIDs(mpull($merchants, 'getPHID')) | ||||
->withEdgeTypes(array(PhortuneMerchantHasMemberEdgeType::EDGECONST)); | ->withEdgeTypes(array(PhortuneMerchantHasMemberEdgeType::EDGECONST)); | ||||
$query->execute(); | $query->execute(); | ||||
Show All 30 Lines | if ($this->needProfileImage) { | ||||
} | } | ||||
$merchant->attachProfileImageFile($file); | $merchant->attachProfileImageFile($file); | ||||
} | } | ||||
} | } | ||||
return $merchants; | return $merchants; | ||||
} | } | ||||
protected function buildWhereClause(AphrontDatabaseConnection $conn) { | protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { | ||||
$where = array(); | $where = parent::buildWhereClauseParts($conn); | ||||
if ($this->ids !== null) { | if ($this->ids !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn, | $conn, | ||||
'id IN (%Ld)', | 'id IN (%Ld)', | ||||
$this->ids); | $this->ids); | ||||
} | } | ||||
if ($this->phids !== null) { | if ($this->phids !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn, | $conn, | ||||
'phid IN (%Ls)', | 'phid IN (%Ls)', | ||||
$this->phids); | $this->phids); | ||||
} | } | ||||
if ($this->memberPHIDs !== null) { | if ($this->memberPHIDs !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn, | $conn, | ||||
'e.dst IN (%Ls)', | 'e.dst IN (%Ls)', | ||||
$this->memberPHIDs); | $this->memberPHIDs); | ||||
} | } | ||||
$where[] = $this->buildPagingClause($conn); | return $where; | ||||
return $this->formatWhereClause($conn, $where); | |||||
} | } | ||||
protected function buildJoinClause(AphrontDatabaseConnection $conn) { | protected function buildJoinClauseParts(AphrontDatabaseConnection $conn) { | ||||
$joins = array(); | $joins = parent::buildJoinClauseParts($conn); | ||||
if ($this->memberPHIDs !== null) { | if ($this->memberPHIDs !== null) { | ||||
$joins[] = qsprintf( | $joins[] = qsprintf( | ||||
$conn, | $conn, | ||||
'LEFT JOIN %T e ON m.phid = e.src AND e.type = %d', | 'LEFT JOIN %T e ON m.phid = e.src AND e.type = %d', | ||||
PhabricatorEdgeConfig::TABLE_NAME_EDGE, | PhabricatorEdgeConfig::TABLE_NAME_EDGE, | ||||
PhortuneMerchantHasMemberEdgeType::EDGECONST); | PhortuneMerchantHasMemberEdgeType::EDGECONST); | ||||
} | } | ||||
return implode(' ', $joins); | return $joins; | ||||
} | } | ||||
public function getQueryApplicationClass() { | public function getQueryApplicationClass() { | ||||
return 'PhabricatorPhortuneApplication'; | return 'PhabricatorPhortuneApplication'; | ||||
} | } | ||||
protected function getPrimaryTableAlias() { | |||||
return 'm'; | |||||
} | |||||
} | } |