Пример #1
0
 /**
  * Set options
  * 
  * @return void
  */
 protected function _setOptions()
 {
     if (is_string($this->_model)) {
         $this->_model = new $this->_model();
     }
     $queryBuilder = $this->_model->queryBuilder();
     $this->_options = \Engine\Crud\Tools\Multiselect::prepareOptions($queryBuilder, $this->_optionName, $this->category, $this->categoryName, $this->where, $this->emptyCategory, $this->emptyItem, $this->fields);
 }
Пример #2
0
 /**
  * Set model default order to query
  *
  * @param bool $reverse
  * @return \Engine\Mvc\Model\Query\Builder
  */
 public function orderNatural($reverse = false)
 {
     $direction = $this->_model->getOrderAsc();
     if ($order = $this->_model->getOrderExpr()) {
         if (!is_array($order)) {
             $order = [$order];
         }
         if (!is_array($direction)) {
             $direction = [$direction];
         }
         $orderPre = [];
         foreach ($order as $i => $key) {
             $direction[$i] = $direction[$i] ^ $reverse ? "ASC" : "DESC";
             $alias = $this->getCorrelationName($key);
             $orderPre[] = $alias . "." . $key . " " . $direction[$i];
         }
         $this->orderBy(implode(",", $orderPre));
     }
     return $this;
 }