In this example i am going to show you how to get the last insert id after insert data in database.
function save_data($student_data){
$this->db->insert('student_db', $student_data);
$insert_id = $this->db->insert_id();
return $insert_id;
}
$this->db->insert('student_db', $student_data);
$insert_id = $this->db->insert_id();
return $insert_id;
}
insert_id() function will return zero if table does not have auto incremented column so make sure table must have a column with AUTO_INCREMENT attribute.
0 comments:
Post a Comment
Thanks