繁体   English   中英

Codeigniter您必须使用“设置”方法来更新条目5

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

我会竭尽全力,但不工作。

模型

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);

}

控制者

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');

}

作为调试的第一步,我将打印查询,并通过使用以下命令查看它是否正确

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

如果您尝试先设置数据怎么办?

public  function updatecareer($id,$data){  

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

    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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