[英]Error:You must use the “set” method to update an entry
我使用Codeigniter作為我的PHP框架,當我將數據提交到數據庫時,我一直收到此錯誤。
我已經在控制器中使用了set。 我不知道為什么會出現這個錯誤:
您必須使用“set”方法更新條目
我的模特:
public function update_reserve($data,$book_id)
{
$this->db->where('book_id',$book_id);
$this->db->update('books',$data);
return TRUE;
}
我的控制器:
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);
}
}
}
在模型中,您可以使用“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;
}
我想你應該像這樣打電話給你的方法
$this->user_model->update_reserve($data,$book_id);
看結果
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.