[英]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.