php - Issue in disabling function in CODEIGNITER -


this question exact duplicate of:

i realized significant problem in application. it's apply , hire functions. ideally, applicant can apply once job post.however, happens in program not this. after more tests, realized, applicant can send two, three, 4 , on should not case. correspondingly, client can hire or reject applicant more once (depending on number of proposals sent), what's more erroneous is, applicant has been hired, if client clicks reject button on proposals page, status changes "approved" rejected.

i think should change in part:

 public function add_job_proposal_from_provider($obj)  {     if ($obj['proposal'] == null){     $data = array     (         'proposal' => $obj['proposal'],         'job_id' => $obj['job_id'],         'status' => "open",         'provider_id' => $this->auth_model->get_user_id()     );      $this->db->insert('job_proposal', $data);     }  } 

in terms of application.. looking forward help.

you check database before insert, ensure there no proposal user particular job. here's brief example add start of add_job_proposal_from_provider($obj) method:

$this->db->from('job_proposal'); $this->db->where('job_id', $obj['job_id']); $this->db->where('provider_id', $this->auth_model->get_user_id()); $result = $this->db->get(); if ($result->num_rows() > 0) {     // set error message?     return; } 

alternatively, set unique index in database across job_id , provider_id fields. example in mysql is:

alter table job_proposal add unique index(provider_id, job_id); 

Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -