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

/**
 * 原创书籍列表
 *
 * @author yzxh24
 */
class ListAction extends BaseAction
{
    public function run()
    {
    	$criteria = $this->_buildCriteria(new CDbCriteria(array('with'=>array('types', 'authors'))));
        $criteria->compare('t.type','=2');
        //put your code here
        $dataProvider = new CActiveDataProvider('Books',array(
        	'pagination' => array(
        		'pageSize' => 20
        	),
        	'sort' => array(
        		'defaultOrder' => 't.updatedate DESC',
        	),
        ));
        $dataProvider->setCriteria($criteria);

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

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