{ $ret = $this->student->validate(); if (!$ret) { $this->addErrors($this->student->getErrors()); } } public function save() { //start a transaction $transaction = Yii::app()->db->beginTransaction(); try { if ($this->user->isNewRecord) { $this->user->is_verified = 0; $verification = new UserVerification(); } //try to save the data to db $ret = parent::save(); if ($ret) { $ret = $this->student->save(true, null, $this->user); if (isset($verification)) { Yii::log("Verification is set"); $verification->user_id = $this->user->user_id; $this->hash = $verification->generateHash(); if (!$verification->save()) { throw new Exception(); } if (!Emailer::emailStudentActivation($this->user, $this->hash)) { throw new Exception(); } } } $transaction->commit(); //Yii::app()->user->setFlash('success',sprintf(Constants::SUCCESS_SURVEY_SUBMITTED,$model->getSurvey()->title)); return $ret; } catch (Exception $e) {