Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/query/DiffusionPathQuery.php
<?php | <?php | ||||
final class DiffusionPathQuery extends Phobject { | final class DiffusionPathQuery extends Phobject { | ||||
private $pathIDs; | private $pathIDs; | ||||
public function withPathIDs(array $path_ids) { | public function withPathIDs(array $path_ids) { | ||||
$this->pathIDs = $path_ids; | $this->pathIDs = $path_ids; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function execute() { | public function execute() { | ||||
$conn_r = id(new PhabricatorRepository())->establishConnection('r'); | $conn = id(new PhabricatorRepository())->establishConnection('r'); | ||||
$where = $this->buildWhereClause($conn_r); | $where = $this->buildWhereClause($conn); | ||||
$results = queryfx_all( | $results = queryfx_all( | ||||
$conn_r, | $conn, | ||||
'SELECT * FROM %T %Q', | 'SELECT * FROM %T %Q', | ||||
PhabricatorRepository::TABLE_PATH, | PhabricatorRepository::TABLE_PATH, | ||||
$where); | $where); | ||||
return ipull($results, null, 'id'); | return ipull($results, null, 'id'); | ||||
} | } | ||||
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { | protected function buildWhereClause(AphrontDatabaseConnection $conn) { | ||||
$where = array(); | $where = array(); | ||||
if ($this->pathIDs) { | if ($this->pathIDs) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn_r, | $conn, | ||||
'id IN (%Ld)', | 'id IN (%Ld)', | ||||
$this->pathIDs); | $this->pathIDs); | ||||
} | } | ||||
if ($where) { | if ($where) { | ||||
return 'WHERE ('.implode(') AND (', $where).')'; | return qsprintf($conn, 'WHERE %LA', $where); | ||||
} else { | } else { | ||||
return ''; | return qsprintf($conn, ''); | ||||
} | } | ||||
} | } | ||||
} | } |