简体   繁体   English

错误:您必须使用“set”方法更新条目

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

相关问题 错误:您必须使用“set”方法来更新条目修复? - Error: You must use the "set" method to update an entry fix? CodeIgniter DataMapper错误:您必须使用“set”方法来更新条目 - CodeIgniter DataMapper Error: You must use the “set” method to update an entry 发生数据库错误:您必须使用“set”方法来更新条目 - A Database Error Occurred: You must use the "set" method to update an entry CI4 您必须使用“设置”方法来更新条目。 已经用set了,还是报错 - CI4 You must use the "set" method to update an entry. Already use set, still error Codeigniter您必须使用“设置”方法来更新条目5 - Codeigniter You must use the “set” method to update an entry 5 Codeigniter:您必须使用“set”方法来更新条目 - Codeigniter: You must use the “set” method to update an entry 您必须使用“set”方法来更新条目如何在 php codenniter 中纠正 - You must use the "set" method to update an entry how to rectify in php codengniter Codeigniter4 显示即使我使用了“set”方法,运行更新查询时也必须使用“set”方法 - Codeigniter4 shows You must use the "set" method when running update query even I used "set" method 必须使用设定方法 - Must use set method 保存时,如何解决“设置”方法来更新条目。 在控制器上添加表单验证后 - When saving, how to fix “set” method to update an entry. after add form validation on controllers
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM