<?php
class IndexAction extends BaseAction
{
    public function run()
    {
        $criteria = $this->_buildCriteria(new CDbCriteria(array('with'=>array('data','member'),'condition'=>'msgtoid<>0 AND isdelete = 0')));

        $dataProvider = new CActiveDataProvider('Messages',array('pagination' => array('pageSize' => 20),'sort'=>array('defaultOrder'=>'mid DESC')));
        $dataProvider->setCriteria($criteria);
        
        $this->getController()->render('index', array(
			'dataProvider' => $dataProvider,
		));
    }
    
	/**
     * 根据url后面传递进来的参数获取一个查询条件
     * @param CDbCriteria $criteria
     * @return CDbCriteria
     */
    private function _buildCriteria(CDbCriteria $criteria)
    {
    	// 完善此功能
    	return Helper::buildCriteria($criteria, $_GET);
    }
}