コード例 #1
0
 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;
     }
 }
コード例 #2
0
 public function actionDeleteSelected()
 {
     if (isset($_GET['ajax'])) {
         if (isset($_POST) && isset($_POST['stu_job_id']) && !empty($_POST['stu_job_id'])) {
             try {
                 if (FavoriteStudentJobTitle::deleteResumes($_POST['stu_job_id'], Yii::app()->user->id)) {
                     $this->renderPartial('//common/_alerts', array('type' => 'success', 'msg' => Yii::t('app', 'msg.success.del_fav_resumes')));
                 }
             } catch (Exception $e) {
                 $this->renderPartial('//common/_alerts', array('type' => 'danger', 'msg' => Yii::t('app', 'msg.error.del_fav_resumes')));
             }
             return;
         }
         $this->renderPartial('//common/_alerts', array('type' => 'danger', 'msg' => Yii::t('app', 'msg.error.resumes_not_found')));
     }
 }
コード例 #3
0
 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;
     }
 }