[英]Error:You must use the “set” method to update an entry
I am using Codeigniter as my PHP framework, and I keep getting this error when I submit my data to my database. 我使用Codeigniter作为我的PHP框架,当我将数据提交到数据库时,我一直收到此错误。
I am already using set in the controller. 我已经在控制器中使用了set。 I am not sure why I have this error:
我不知道为什么会出现这个错误:
You must use the “set” method to update an entry
您必须使用“set”方法更新条目
My model: 我的模特:
public function update_reserve($data,$book_id)
{
$this->db->where('book_id',$book_id);
$this->db->update('books',$data);
return TRUE;
}
My controller: 我的控制器:
public function out()
{
$book_id = $this->input->post('book_id');
if(isset($_POST['btn_reserve'])) {
$data = array(
'pickup' =>$this->input->post('pickup'),
'return' =>$this->input->post('return'),);
if(!empty($data)) {
$this->user_model->update_reserve($book_id,$data);
}
}
}
In model, You can use "set" method: 在模型中,您可以使用“set”方法:
public function update_reserve($data,$book_id)
{
$this->db->where('book_id',$book_id);
$this->db->set($data);
$this->db->update('books');
return TRUE;
}
I think you should call your method like this 我想你应该像这样打电话给你的方法
$this->user_model->update_reserve($data,$book_id);
to see result 看结果
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.