forked from phacility/phabricator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConpherenceParticipantQuery.php
50 lines (38 loc) · 1.25 KB
/
ConpherenceParticipantQuery.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
final class ConpherenceParticipantQuery extends PhabricatorOffsetPagedQuery {
private $participantPHIDs;
public function withParticipantPHIDs(array $phids) {
$this->participantPHIDs = $phids;
return $this;
}
public function execute() {
$table = new ConpherenceParticipant();
$thread = new ConpherenceThread();
$conn = $table->establishConnection('r');
$data = queryfx_all(
$conn,
'SELECT * FROM %T participant JOIN %T thread
ON participant.conpherencePHID = thread.phid %Q %Q %Q',
$table->getTableName(),
$thread->getTableName(),
$this->buildWhereClause($conn),
$this->buildOrderClause($conn),
$this->buildLimitClause($conn));
return $table->loadAllFromArray($data);
}
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array();
if ($this->participantPHIDs !== null) {
$where[] = qsprintf(
$conn,
'participantPHID IN (%Ls)',
$this->participantPHIDs);
}
return $this->formatWhereClause($conn, $where);
}
private function buildOrderClause(AphrontDatabaseConnection $conn) {
return qsprintf(
$conn,
'ORDER BY thread.dateModified DESC, thread.id DESC, participant.id DESC');
}
}