SQL

// AR SQL Ограничение вывода public function SqlLimit(&$sql) { $this->_limit = (int)Yii::app()->request->getParam('limit'); $this->_offset = (int)Yii::app()->request->getParam('offset'); if($this->_limit) $sql .= ' LIMIT ' . $this->_limit; if($this->_offset) $sql .= ' OFFSET ' . $this->_offset; return $this; }
// AR SQL Ограничение вывода public function SqlOrder(&$sql, $order = '') { $this->_order = (string)Yii::app()->request->getParam('order'); if($order == '') $order = $this->_order; // Если -$order то $desc = true; if($order[0] == '-') $desc = true; $order = preg_replace('~[^a-z]~', '', $order); $sql .= ' ORDER BY ' . $order . (isset($desc) ? ' DESC ' : ''); return $this; }