i’m new to Codeigniter, but learning from web, actually i got stuck with a unknown proble.
im inserting data into the database throw the model, and fetching back the data into form.
but when i’m updating the form i want to return the updated id.
i used $user_id = $this->db->insert_id();
but this is for getting insert id,
even i tried this
JavaScript
x
$this->db->where('id_colum', $student_id);
$this->db->update('table_name', $data);
$user_id = $this->db->insert_id();
return $user_id;
help me out, Thanks for everything..
Advertisement
Answer
Just do like this:
JavaScript
$this->db->where('id_colum', $student_id);
$this->db->update('table_name', $data);
$updated_status = $this->db->affected_rows();
if($updated_status):
return $student_id;
else:
return false;
endif;
If it is updated, then return back that $student_id. 🙂