whenever get last insert id using codeigniter then id will comes 0 code example
Example 1: return last insert id in codeigniter
$id = $this->db->insert_id();
Example 2: codeigniter last insert id
$last_inserted_id = $this->db->insert_id();
$id = $this->db->insert_id();
$last_inserted_id = $this->db->insert_id();