Model
Создать компонент от CActiveRecord и наследловаться от созданного
public $_limit = 10; public $_offset = 0; public $_order = '';
// AR Limit, Offset public function limit($limit = 0, $offset = 0) { $this->_limit = (int)Yii::app()->request->getParam('limit'); $this->_offset = (int)Yii::app()->request->getParam('offset'); $this->getDbCriteria()->mergeWith( array( 'limit' => $limit ? $limit : $this->_limit, 'offset' => $offset ? $offset : $this->_offset, ) ); return $this; } // AR Group public function group($group = array()) { if(is_array($group)) $_group = $group; else $_group[] = $group; $this->getDbCriteria()->mergeWith( array( 'group' => implode(',', $_group), ) ); return $this; } // AR Order by public function order($order = '', $desc = false) { $this->_order = (string)Yii::app()->request->getParam('order'); if($order == '') $order = $this->_order; if(!$order) return $this; $this->getDbCriteria()->mergeWith( array( 'order' => $order . ($desc? ' DESC': ' ASC'), ) ); return $this; }