[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

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

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


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