public function actionDelete($id) { if (isset($_GET['ajax'])) { if (isset($id)) { $empFavRes = FavoriteStudentJobTitle::model()->findByAttributes(array('stu_job_id' => $id, 'employer_id' => Yii::app()->user->id)); if ($empFavRes != null) { if ($empFavRes->delete()) { $this->renderPartial('//common/_alerts', array('type' => 'success', 'msg' => Yii::t('app', 'msg.success.del_fav_resume'))); } else { $this->renderPartial('//common/_alerts', array('type' => 'danger', 'msg' => Yii::t('app', 'msg.error.del_fav_resume'))); } return; } } $this->renderPartial('//common/_alerts', array('type' => 'danger', 'msg' => Yii::t('app', 'msg.error.resume_not_found'))); } }
public static function deleteResumes($resumes, $empId) { if (!isset($resumes) || !is_array($resumes) || !isset($empId)) { throw new CException('Resumes and Employer Id are required'); } $resCount = count($resumes); if ($resCount === 0) { return true; } $transaction = Yii::app()->db->beginTransaction(); try { $deletedCount = FavoriteStudentJobTitle::model()->deleteAllByAttributes(array('stu_job_id' => $resumes, 'employer_id' => $empId)); if ($deletedCount !== $resCount) { throw new CException("Only {$deletedCount} records deleted, while deleting {$resCount} records."); } $transaction->commit(); return true; } catch (Exception $e) { $transaction->rollback(); throw $e; } }
public function delete() { $tr = Yii::app()->db->beginTransaction(); try { FavoriteStudentJobTitle::model()->deleteAllByAttributes(array('stu_job_id' => $this->stu_job_id)); InterviewStudentJobTitle::model()->deleteAllByAttributes(array('stu_job_id' => $this->stu_job_id)); parent::delete(); $tr->commit(); return true; } catch (Exception $e) { $tr->rollback(); throw $e; } }