return last insert id in codeigniter
snippet in php

return last insert id in codeigniter

user8247

$id = $this->db->insert_id();

last insert id model codeigniter

user2054

function add_post($post_data){
   $this->db->insert('posts', $post_data);
   $insert_id = $this->db->insert_id();

   return  $insert_id;
}