Пример #1
0
 /**
  * Set datasource
  * 
  * @return void
  */
 protected function _setDataSource()
 {
     $this->_dataSource = $this->_model->queryBuilder();
     foreach ($this->_joins as $table) {
         $this->_dataSource->columnsJoinOne($table);
     }
     $this->_dataSource->columns($this->_columns);
     foreach ($this->_conditions as $cond) {
         if (is_array($cond)) {
             $this->_dataSource->addWhere($cond['cond'], $cond['params']);
         } else {
             $this->_dataSource->addWhere($cond);
         }
     }
     $sort = $this->_grid->getSortKey();
     if (null === $sort) {
         $sort = $this->_model->getOrderExpr();
     }
     $direction = $this->_grid->getSortDirection();
     if (null === $direction) {
         $direction = $this->_model->getOrderAsc() ? "ASC" : "DESC";
     }
     if ($sort) {
         $alias = $this->_dataSource->getCorrelationName($sort);
         if ($alias) {
             $sort = $alias . "." . $sort;
         }
         if ($direction) {
             $this->_dataSource->orderBy($sort . ' ' . $direction);
         } else {
             $this->_dataSource->orderBy($sort);
         }
     }
 }
Пример #2
0
 /**
  * Set datasource
  *
  * @return void
  */
 protected function _setDataSource()
 {
     $this->_dataSource = $this->_model->queryBuilder();
     foreach ($this->_joins as $table) {
         $this->_dataSource->columnsJoinOne($table);
     }
     $this->_dataSource->columns($this->_columns);
     foreach ($this->_conditions as $cond) {
         if (is_array($cond)) {
             $this->_dataSource->addWhere($cond['cond'], $cond['params']);
         } else {
             $this->_dataSource->addWhere($cond);
         }
     }
     $sort = $this->_grid->getSortKey();
     $direction = $this->_grid->getSortDirection();
     if (!empty($sort)) {
         if (!empty($direction)) {
             $this->_dataSource->orderBy($this->_grid->getSortKey() . ' ' . $this->_grid->getSortDirection());
         } else {
             $this->_dataSource->orderBy($this->_grid->getSortKey());
         }
     }
 }