<?php

/**
 * This is the model class for table "{{paper}}".
 *
 * The followings are the available columns in table '{{paper}}':
 * @property integer $paper_id
 * @property integer $paper_release_id
 * @property string $paper_url
 * @property string $paper_time
 * @property integer $paper_editor_id
 * @property integer $paper_filesize
 * @property integer $paper_site_id
 * @property string $paper_name_cn
 * @property string $paper_editor
 * @property string $paper_pdf
 * @property string $paper_timestamp
 * @property string $paper_html_url
 * @property string $paper_editionnumber
 */
class Paper extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Paper the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{paper}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('paper_release_id, paper_editor_id, paper_filesize, paper_site_id', 'numerical', 'integerOnly'=>true),
			array('paper_url', 'length', 'max'=>400),
			array('paper_time, paper_timestamp', 'length', 'max'=>13),
			array('paper_name_cn, paper_editor, paper_pdf, paper_html_url', 'length', 'max'=>400),
			array('paper_editionnumber', 'length', 'max'=>100),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('paper_id, paper_release_id, paper_url, paper_time, paper_editor_id, paper_filesize, paper_site_id, paper_name_cn, paper_editor, paper_pdf, paper_timestamp, paper_html_url, paper_editionnumber', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'paper_id' => 'Paper',
			'paper_release_id' => 'Paper Release',
			'paper_url' => 'Paper Url',
			'paper_time' => 'Paper Time',
			'paper_editor_id' => 'Paper Editor',
			'paper_filesize' => 'Paper Filesize',
			'paper_site_id' => 'Paper Site',
			'paper_name_cn' => 'Paper Name Cn',
			'paper_editor' => 'Paper Editor',
			'paper_pdf' => 'Paper Pdf',
			'paper_timestamp' => 'Paper Timestamp',
			'paper_html_url' => 'Paper Html Url',
			'paper_editionnumber' => 'Paper Editionnumber',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('paper_id',$this->paper_id);
		$criteria->compare('paper_release_id',$this->paper_release_id);
		$criteria->compare('paper_url',$this->paper_url,true);
		$criteria->compare('paper_time',$this->paper_time,true);
		$criteria->compare('paper_editor_id',$this->paper_editor_id);
		$criteria->compare('paper_filesize',$this->paper_filesize);
		$criteria->compare('paper_site_id',$this->paper_site_id);
		$criteria->compare('paper_name_cn',$this->paper_name_cn,true);
		$criteria->compare('paper_editor',$this->paper_editor,true);
		$criteria->compare('paper_pdf',$this->paper_pdf,true);
		$criteria->compare('paper_timestamp',$this->paper_timestamp,true);
		$criteria->compare('paper_html_url',$this->paper_html_url,true);
		$criteria->compare('paper_editionnumber',$this->paper_editionnumber,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}