/** * 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 User the static model class */ public static function model($className = __CLASS__) { return parent::model($className); }
/** * 密码的处理 */ protected function beforeSave() { parent::beforeSave(); if ($this->isNewRecord) { $this->password = $this->encrypt($this->password); } else { if ($this->getScenario() == 'update') { $olduser = User::model()->findByPk($this->id); if ($olduser->password != $this->password) { $this->password = $this->encrypt($this->password); } } } return true; }