开发者

Problem in updating field in codeigniter please help

It says , you must use the “set” method to update an entry. Pls help

My model is

$this->db->where('id', $this->uri->segment(3));
$this->db->update('mytable', $data);

My controller is

$data = $this->db->select('mytable', $_POST);
$this->contact_model->开发者_StackOverflow;model_update_function($data); 


Your $data variable doesn't contain a valid array. This is because $this->db->select(); doesn't actually run the query, you need $this->db->get(); or $this->db->get_where(); in order to do so. Even then, you also need to call $query->result(); to retrieve the data from the result.

Your controller should be

$query = $this->db->get_where('mytable', $_POST);
$data = $query->result();
$this->contact_model->model_update_function($data); 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜