[eluser]Dan Bowling[/eluser]
I don't see on the user guide how to determine problems when using $this->db->update().
If there is a problem, how do I know what it is?
Right now I'm using this code for my controller:
Code:
function update($id, $column)
{
$value = $this->input->get_post('value');
$this->regions_model->update($column, $value, $id);
if($this->db->affected_rows() > 0){
$this->session->set_flashdata('flash', '<p class="success">Region updated</p>');
}
else {
$this->session->set_flashdata('flash', '<p class="fail">Error! Region was not updated</p>');
}
redirect('/regions/view/' . $id, 'refresh');
}
and this for the model:
Code:
function update($column, $value, $id)
{
$this->db->where('region_id', $id);
$data = array(
$column => $value
);
$this->db->update('regions', $data);
}
The value sometimes doesn't update, and for the life of me, I can't figure out why.
I'm sure you can tell I'm pretty new at this by my code. Any feedback to help me learn is greatly appreciated.