db->prepare($sql); $result = $stmt->execute([ "job_id" => $application->getJobId(), "name" => $application->getName(), "gender" => $application->getGender(), "email" => $application->getEmail(), "second_email" => $application->getSecondEmail(), "phone" => $application->getPhone(), "second_phone" => $application->getSecondPhone(), "latest_company" => $application->get_latest_company(), "latest_job_title" => $application->get_latest_job_title(), "gradute_school" => $application->get_gradute_school(), "gradute_master" => $application->get_gradute_master(), "experience" => $application->get_experience(), "english_ability_id" => $application->get_english_ability_id(), "other" => $application->getOther(), "apply_user_id" => $application->get_apply_user_id(), "highest_education_id" => $application->get_highest_education_id(), "graduate_year" => $application->get_graduate_year(), "age_year" => $application->get_age_year(), "cv_path" => $application->getCVpath(), "send_time" => $application->get_send_time() ]); if(!$result) { throw new Exception("could not save record"); } } public function checkDuplicateApply( $job_id, $apply_user_id ){ $sql = "SELECT * FROM `application` WHERE `job_id`=".$job_id." and `apply_user_id`=".$apply_user_id; // print($sql); $stmt = $this->db->query($sql); if( $stmt->rowCount() == 0 ){ return array('success'=>'無申請過此工作'); }else{ return array('error'=>'您有申請過該工作,請問確定再次寄出職缺申請嗎?'); } } public function getApplicationByUser($user_id){ $sql = "SELECT j.company, j.job_title, a.* from application a join jobs j on (j.id = a.job_id) where a.apply_user_id =".$user_id; $stmt = $this->db->query($sql); $results = []; while($row = $stmt->fetch()) { $results[] = new ApplicationEntity($row); } return $results; } public function getApplicationByJobIdAndUser($job_id, $user_id){ $sql = "SELECT j.company, j.job_title, a.* from application a join jobs j on (j.id = a.job_id) where a.apply_user_id =".$user_id . ' AND job_id=' . $job_id . ' ORDER BY id DESC'; return $this->_getOne($sql, [], $this->entityClass); } }