1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-22 18:28:47 +02:00
phorge-phorge/src/applications/diffusion/query/DiffusionPathQuery.php

44 lines
803 B
PHP
Raw Normal View History

<?php
final class DiffusionPathQuery {
private $pathIDs;
public function withPathIDs(array $path_ids) {
$this->pathIDs = $path_ids;
return $this;
}
public function execute() {
$conn_r = id(new PhabricatorRepository())->establishConnection('r');
$where = $this->buildWhereClause($conn_r);
$results = queryfx_all(
$conn_r,
'SELECT * FROM %T %Q',
PhabricatorRepository::TABLE_PATH,
$where);
return ipull($results, null, 'id');
}
private function buildWhereClause($conn_r) {
$where = array();
if ($this->pathIDs) {
$where[] = qsprintf(
$conn_r,
'id IN (%Ld)',
$this->pathIDs);
}
if ($where) {
return 'WHERE ('.implode(') AND (', $where).')';
} else {
return '';
}
}
}