<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * 广告票列表
 *
 * @author yzxh24
 */
class AdsAction extends BaseAction
{
    public function run()
    {
    	$criteria = $this->_buildCriteria(new CDbCriteria(array('condition'=>'type = 2')));
        //put your code here
        $dataProvider = new CActiveDataProvider('Adb',array(
        	'pagination' => array(
        		'pageSize' => 20
        	),
        	'sort' => array(
        		'defaultOrder' => 'adid DESC',
        	),
        ));
        $dataProvider->setCriteria($criteria);

        // 总访问
        $criteria->select = 'SUM(day) AS count';
        $count = Adb::model()->find($criteria);
        $criteria->select = '*';

		$this->getController()->render('list', array(
			'dataProvider' => $dataProvider,
            'count' => $count,
		));
    }

    /**
     * 根据url后面传递进来的参数获取一个查询条件
     * @param CDbCriteria $criteria
     * @return CDbCriteria
     */
    private function _buildCriteria(CDbCriteria $criteria)
    {
    	// 完善此功能
    	return $criteria;
    }
}