protected function loadPage() { $table = new HeraldRule(); $conn_r = $table->establishConnection('r'); $data = queryfx_all($conn_r, 'SELECT rule.* FROM %T rule %Q %Q %Q', $table->getTableName(), $this->buildWhereClause($conn_r), $this->buildOrderClause($conn_r), $this->buildLimitClause($conn_r)); return $table->loadAllFromArray($data); }
public function execute() { $table = new HeraldRule(); $conn_r = $table->establishConnection('r'); $where = $this->buildWhereClause($conn_r); $order = $this->buildOrderClause($conn_r); $limit = $this->buildLimitClause($conn_r); $data = queryfx_all($conn_r, 'SELECT rule.* FROM %T rule %Q %Q %Q', $table->getTableName(), $where, $order, $limit); return $table->loadAllFromArray($data); }
private function queryRules(AphrontPagerView $pager) { $rule = new HeraldRule(); $conn_r = $rule->establishConnection('r'); $where_clause = qsprintf($conn_r, 'WHERE contentType = %s', $this->view); if ($this->viewPHID) { $where_clause .= qsprintf($conn_r, ' AND authorPHID = %s', $this->viewPHID); } $data = queryfx_all($conn_r, 'SELECT * FROM %T %Q ORDER BY id DESC LIMIT %d, %d', $rule->getTableName(), $where_clause, $pager->getOffset(), $pager->getPageSize() + 1); $data = $pager->sliceResults($data); $rules = $rule->loadAllFromArray($data); $need_phids = mpull($rules, 'getAuthorPHID'); if ($this->viewPHID) { $need_phids[] = $this->viewPHID; } $handles = id(new PhabricatorObjectHandleData($need_phids))->loadHandles(); return array($rules, $handles); }