Check out example codes for "codeigniter return last inserted id". It will help you in understanding the concepts better.

Code Example 1

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

Code Example 2

$this->db->insert('posts', $post_data);
   $insert_id = $this->db->insert_id();
   return  $insert_id;

Learn ReactJs, React Native from akashmittal.com