tags:

views:

47

answers:

1

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->model_update_function($data); 
A: 

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); 
Zackman
Thank you zackman, what do i need to do in order to update in multiple tables ? Thanks
sagarmatha
What exactly are you trying to do? Just run the code in your model multiple times - once for each table.
Zackman