/** * @return array customized attribute labels (name=>label) */ public function attributeLabels() { return array('ID' => 'ID', 'Name' => '名字', 'Tel' => '电话', 'Email' => 'Email', 'Content' => '内容', 'Reply' => '回复', 'CreateTime' => '发布时间', 'UpdateTime' => '更新时间'); } /** * 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() {
public function beforeSave() { if (parent::beforeSave()) { if ($this->isNewRecord) { $this->CreateTime = $this->UpdateTime = time(); $this->AuthorID = Yii::app()->user->id; } else { $this->UpdateTime = time(); } return true; } else { return false; } }
/** * Returns the static model of the specified AR class. * Please note that you should have this exact method in all your CActiveRecord descendants! * @param string $className active record class name. * @return Make the static model class */ public static function model($className = __CLASS__) { return parent::model($className); }
public function afterFind() { parent::afterFind(); // 修改时间格式 //if(self::model()->scenario == 'list') { $this->setAttribute('GreateTime', date('Y-m-d H:i:s', $this->getAttribute('createTime'))); $this->setAttribute('UpdateTime', date('Y-m-d H:i:s', $this->getAttribute('updateTime'))); $status = $this->getAttribute('status'); $this->setAttribute('Status', $status == '0' ? '待审核' : ($status == '1' ? '审核通过' : ($status == '2' ? '审核未通过' : '其他'))); //} }
protected function beforeSave() { if (parent::beforeSave()) { if ($this->isNewRecord) { $this->CreateTime = time(); $this->UpdateTime = time(); $this->OrganID = Yii::app()->user->getOrganID(); } else { $this->CreateTime = time(); $this->UpdateTime = time(); $this->OrganID = Yii::app()->user->getOrganID(); } return true; } else { return false; } }