/**
  * {@inheritdoc}
  */
 public function order($columnOrAlias, $dir = null)
 {
     foreach ($this->subQueries as $sub) {
         $sub->requireColumn($columnOrAlias);
     }
     return parent::order($columnOrAlias, $dir);
 }
Exemple #2
0
 /**
  * Sort the rows, according to the specified sort column and order
  *
  * @param   string  $column Sort column
  * @param   string  $order  Sort order, one of the SORT_ constants
  *
  * @return  $this
  * @throws  QueryException  If the sort column is not allowed
  * @see     DataView::SORT_ASC
  * @see     DataView::SORT_DESC
  * @deprecated Use DataView::order() instead
  */
 public function sort($column = null, $order = null)
 {
     $sortRules = $this->getSortRules();
     if ($column === null) {
         // Use first available sort rule as default
         if (empty($sortRules)) {
             return $this;
         }
         $sortColumns = reset($sortRules);
         if (!isset($sortColumns['columns'])) {
             $sortColumns['columns'] = array(key($sortRules));
         }
     } else {
         if (isset($sortRules[$column])) {
             $sortColumns = $sortRules[$column];
             if (!isset($sortColumns['columns'])) {
                 $sortColumns['columns'] = array($column);
             }
         } else {
             $sortColumns = array('columns' => array($column), 'order' => $order);
         }
     }
     $order = $order === null ? isset($sortColumns['order']) ? $sortColumns['order'] : static::SORT_ASC : $order;
     $order = strtoupper($order) === static::SORT_ASC ? 'ASC' : 'DESC';
     foreach ($sortColumns['columns'] as $column) {
         list($column, $direction) = $this->query->splitOrder($column);
         if (!$this->isValidFilterTarget($column)) {
             throw new QueryException(mt('monitoring', 'The sort column "%s" is not allowed in "%s".'), $column, get_class($this));
         }
         $this->query->order($column, $direction !== null ? $direction : $order);
     }
     $this->isSorted = true;
     return $this;
 }