[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/countdown/query/ -> PhabricatorCountdownQuery.php (source)

   1  <?php
   2  
   3  final class PhabricatorCountdownQuery
   4    extends PhabricatorCursorPagedPolicyAwareQuery {
   5  
   6    private $ids;
   7    private $phids;
   8    private $authorPHIDs;
   9    private $upcoming;
  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 withAuthorPHIDs(array $author_phids) {
  22      $this->authorPHIDs = $author_phids;
  23      return $this;
  24    }
  25  
  26    public function withUpcoming($upcoming) {
  27      $this->upcoming = true;
  28      return $this;
  29    }
  30  
  31    protected function loadPage() {
  32      $table = new PhabricatorCountdown();
  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      $countdowns = $table->loadAllFromArray($data);
  44  
  45      return $countdowns;
  46    }
  47  
  48    private function buildWhereClause(AphrontDatabaseConnection $conn_r) {
  49      $where = array();
  50  
  51      $where[] = $this->buildPagingClause($conn_r);
  52  
  53      if ($this->ids) {
  54        $where[] = qsprintf(
  55          $conn_r,
  56          'id IN (%Ld)',
  57          $this->ids);
  58      }
  59  
  60      if ($this->phids) {
  61        $where[] = qsprintf(
  62          $conn_r,
  63          'phid IN (%Ls)',
  64          $this->phids);
  65      }
  66  
  67      if ($this->authorPHIDs) {
  68        $where[] = qsprintf(
  69          $conn_r,
  70          'authorPHID in (%Ls)',
  71          $this->authorPHIDs);
  72      }
  73  
  74      if ($this->upcoming) {
  75        $where[] = qsprintf(
  76          $conn_r,
  77          'epoch >= %d',
  78          time());
  79      }
  80  
  81      return $this->formatWhereClause($where);
  82    }
  83  
  84    public function getQueryApplicationClass() {
  85      return 'PhabricatorCountdownApplication';
  86    }
  87  
  88  }


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