/** * Bulk inserts the supplied list of stu_job_ids with the empId. * * @param array $resumes - array of stu_job_ids * @param integer $empId - the empId that favorites the resumes * * @return boolean - returns true when succeeded or nothing inserted, otherwise exception will be thrown. */ public static function saveResumes($resumes, $empId) { if (!isset($resumes) || !is_array($resumes) || !isset($empId)) { throw new CException('Resumes and Employer Id are required'); } if (count($resumes) == 0) { return true; } $transaction = Yii::app()->db->beginTransaction(); try { foreach ($resumes as $resume) { $fav = new FavoriteStudentJobTitle(); $fav->stu_job_id = intval($resume); $fav->employer_id = intval($empId); if (!$fav->save()) { $transaction->rollback(); throw new CException(implode(', ', $fav->getErrors())); } } $transaction->commit(); return true; } catch (Exception $e) { $transaction->rollback(); throw $e; } }