[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/search/query/ -> PhabricatorSavedQueryQuery.php (source)

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


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