CodeIgniter Laravel PHP Example Javascript jQuery MORE Videos New

Get last insert id after insert query CodeIgniter framework


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;
}

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.


Warning: mysqli_connect(): (HY000/1040): Too many connections in /www/wwwroot/studentstutorial.com/demo/conn/conn.php on line 15
Could not Connect My Sql:Too many connections