[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/nuance/query/ -> NuanceSourceQuery.php (source)

   1  <?php
   2  
   3  final class NuanceSourceQuery
   4    extends NuanceQuery {
   5  
   6    private $ids;
   7    private $phids;
   8    private $creatorPHIDs;
   9    private $types;
  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 withCreatorPHIDs(array $phids) {
  22      $this->CreatorPHIDs = $phids;
  23      return $this;
  24    }
  25  
  26    public function withTypes($types) {
  27      $this->types = $types;
  28      return $this;
  29    }
  30  
  31  
  32    public function loadPage() {
  33      $table = new NuanceSource();
  34      $conn_r = $table->establishConnection('r');
  35  
  36      $data = queryfx_all(
  37        $conn_r,
  38        'SELECT * FROM %T %Q %Q %Q',
  39        $table->getTableName(),
  40        $this->buildWhereClause($conn_r),
  41        $this->buildOrderClause($conn_r),
  42        $this->buildLimitClause($conn_r));
  43  
  44      return $table->loadAllFromArray($data);
  45    }
  46  
  47    protected function buildWhereClause($conn_r) {
  48      $where = array();
  49  
  50      $where[] = $this->buildPagingClause($conn_r);
  51  
  52      if ($this->creatorPHIDs) {
  53        $where[] = qsprintf(
  54          $conn_r,
  55          'creatorPHID IN (%Ls)',
  56          $this->creatorPHIDs);
  57      }
  58  
  59      if ($this->types) {
  60        $where[] = qsprintf(
  61          $conn_r,
  62          'type IN (%Ld)',
  63          $this->types);
  64      }
  65  
  66      if ($this->ids) {
  67        $where[] = qsprintf(
  68          $conn_r,
  69          'id IN (%Ld)',
  70          $this->ids);
  71      }
  72  
  73      if ($this->phids) {
  74        $where[] = qsprintf(
  75          $conn_r,
  76          'phid IN (%Ls)',
  77          $this->phids);
  78      }
  79  
  80      return $this->formatWhereClause($where);
  81    }
  82  
  83  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1