14 class Paper extends CActiveRecord {
24 public static function model($className = __CLASS__) {
25 return parent::model($className);
42 array(
'paper_name',
'length',
'max' => 60),
43 array(
'paper_size',
'length',
'max' => 10),
44 array(
'author_id',
'length',
'max' => 6),
45 array(
'author_name',
'length',
'max' => 20),
46 array(
'rating',
'length',
'max' => 2),
48 array(
'file',
'file',
'types' =>
'pdf'),
51 array(
'id, paper_name, paper_size, author_id, author_name, rating',
'safe',
'on' =>
'search'),
71 'paper_name' =>
'Paper Name',
72 'paper_size' =>
'Paper Size',
73 'author_id' =>
'Author',
74 'author_name' =>
'Author Name',
87 $criteria =
new CDbCriteria;
89 $criteria->compare(
'id', $this->
id,
true);
90 $criteria->compare(
'paper_name', $this->paper_name,
true);
91 $criteria->compare(
'paper_size', $this->paper_size,
true);
92 $criteria->compare(
'author_id', $this->author_id,
true);
93 $criteria->compare(
'author_name', $this->author_name,
true);
94 $criteria->compare(
'rating', $this->rating,
true);
96 return new CActiveDataProvider($this, array(
97 'criteria' => $criteria,
102 if (
$file = CUploadedFile::getInstance($this,
'file')) {
103 $this->paper_name =
$file->name;
104 $this->paper_size =
$file->size;
105 $this->author_id = Yii::app()->user->id;
106 $this->author_name = Yii::app()->user->name;
109 return parent::beforeSave();