Your code will work if you have this code:
var $table = 'your table name' $this->db->insert($this->table,$data1); return $this->db->insert_id();
CodeIgniter insert_id () will return only the insert identifier (), as mentioned earlier, and you will not forget the DB driver name settings in the database.php file, for example
$db['default']['dbdriver'] = 'mysqli';
Nugroho setiawan
source share