[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class DrydockResourceQuery extends DrydockQuery { 4 5 private $ids; 6 private $phids; 7 private $statuses; 8 private $types; 9 private $blueprintPHIDs; 10 11 public function withIDs(array $ids) { 12 $this->ids = $ids; 13 return $this; 14 } 15 16 public function withPHIDs(array $phids) { 17 $this->phids = $phids; 18 return $this; 19 } 20 21 public function withTypes(array $types) { 22 $this->types = $types; 23 return $this; 24 } 25 26 public function withStatuses(array $statuses) { 27 $this->statuses = $statuses; 28 return $this; 29 } 30 31 public function withBlueprintPHIDs(array $blueprint_phids) { 32 $this->blueprintPHIDs = $blueprint_phids; 33 return $this; 34 } 35 36 public function loadPage() { 37 $table = new DrydockResource(); 38 $conn_r = $table->establishConnection('r'); 39 40 $data = queryfx_all( 41 $conn_r, 42 'SELECT resource.* FROM %T resource %Q %Q %Q', 43 $table->getTableName(), 44 $this->buildWhereClause($conn_r), 45 $this->buildOrderClause($conn_r), 46 $this->buildLimitClause($conn_r)); 47 48 $resources = $table->loadAllFromArray($data); 49 50 return $resources; 51 } 52 53 private function buildWhereClause(AphrontDatabaseConnection $conn_r) { 54 $where = array(); 55 56 if ($this->ids) { 57 $where[] = qsprintf( 58 $conn_r, 59 'id IN (%Ld)', 60 $this->ids); 61 } 62 63 if ($this->phids) { 64 $where[] = qsprintf( 65 $conn_r, 66 'phid IN (%Ls)', 67 $this->phids); 68 } 69 70 if ($this->types) { 71 $where[] = qsprintf( 72 $conn_r, 73 'type IN (%Ls)', 74 $this->types); 75 } 76 77 if ($this->statuses) { 78 $where[] = qsprintf( 79 $conn_r, 80 'status IN (%Ls)', 81 $this->statuses); 82 } 83 84 if ($this->blueprintPHIDs) { 85 $where[] = qsprintf( 86 $conn_r, 87 'blueprintPHID IN (%Ls)', 88 $this->blueprintPHIDs); 89 } 90 91 $where[] = $this->buildPagingClause($conn_r); 92 93 return $this->formatWhereClause($where); 94 } 95 96 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |