[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/diviner/query/ -> DivinerBookQuery.php (source)

   1  <?php
   2  
   3  final class DivinerBookQuery extends PhabricatorCursorPagedPolicyAwareQuery {
   4  
   5    private $ids;
   6    private $phids;
   7    private $names;
   8  
   9    public function withIDs(array $ids) {
  10      $this->ids = $ids;
  11      return $this;
  12    }
  13  
  14    public function withPHIDs(array $phids) {
  15      $this->phids = $phids;
  16      return $this;
  17    }
  18  
  19    public function withNames(array $names) {
  20      $this->names = $names;
  21      return $this;
  22    }
  23  
  24    protected function loadPage() {
  25      $table = new DivinerLiveBook();
  26      $conn_r = $table->establishConnection('r');
  27  
  28      $data = queryfx_all(
  29        $conn_r,
  30        'SELECT * FROM %T %Q %Q %Q',
  31        $table->getTableName(),
  32        $this->buildWhereClause($conn_r),
  33        $this->buildOrderClause($conn_r),
  34        $this->buildLimitClause($conn_r));
  35  
  36      return $table->loadAllFromArray($data);
  37    }
  38  
  39    private function buildWhereClause(AphrontDatabaseConnection $conn_r) {
  40      $where = array();
  41  
  42      if ($this->ids) {
  43        $where[] = qsprintf(
  44          $conn_r,
  45          'id IN (%Ld)',
  46          $this->ids);
  47      }
  48  
  49      if ($this->phids) {
  50        $where[] = qsprintf(
  51          $conn_r,
  52          'phid IN (%Ls)',
  53          $this->phids);
  54      }
  55  
  56      if ($this->names) {
  57        $where[] = qsprintf(
  58          $conn_r,
  59          'name IN (%Ls)',
  60          $this->names);
  61      }
  62  
  63      $where[] = $this->buildPagingClause($conn_r);
  64  
  65      return $this->formatWhereClause($where);
  66    }
  67  
  68    public function getQueryApplicationClass() {
  69      return 'PhabricatorDivinerApplication';
  70    }
  71  
  72  }


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