简体   繁体   中英

Codeigniter You must use the “set” method to update an entry 5

i will do all the whay but not work .

Model

public function edit(){  
          $id = $this->uri->segment(3);
          $template['page'] = "careerdetails/edit-career";
          $template['page_title'] = "Edit Careers Details";
         // $template['data'] = $this->career_model->get_careerdetails();
          $template['data'] = $this->career_model->show_career_id($id);
          $this->load->view('template',$template);
 }

public  function updatecareer($id,$data){

    //$this->db->select('careers');
     $this->db->where('id', $id);
     $this->db->update('careers', $data);

}

Controller

public function editcareer(){
     $id= $this->input->post('id');
        $data = array(
                     'jobtitle' => $this->input->post('jobtitle'),
                     'expiriance' => $this->input->post('expiriance'),
                     'qulification' => $this->inpu-   >post('qualifications'),
                     'gender' => $this->input->post('gender'),
                     'description' => $this->input->post('description'),
                     'minsalary' => $this->input->post('minslary'),
                     'maxsalary' => $this->input->post('maxslary'),
                     'joblocation' => $this->input->post('joblocation'),
                     'lastdate' => $this->input->post('lastdate'),
                     ); $this->load->model('career_model');
    $this->career_model->updatecareer($id , $data);
    redirect(base_url().'careersmgr_ctrl/careers_details');

}

As a first step to debug, I would print the query and see if it is correct by using

 echo $this->db->last_query();

what if you try to set the data first?

public  function updatecareer($id,$data){  

         $this->db->set($data);
         $this->db->where('id', $id);
         $this->db->update('careers');

    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM