I am just trying to get the latest auto generated key from the mysql table from codeiginitor. But it is not working some how. I have tried this code
$this->db->insert_id()
as well as
$this->db->mysql_insert_id()
I am getting the following error
Severity: Notice
Message: Undefined property: CI_DB_mysql_driver::$insert_id
is the insert_id function not supported for mysql? How can we make it work?
I am just trying to get the latest auto generated key from the mysql
Share
This is the code I tried to insert the data and get the insert id,
$this->db->insert('table_name',$data);$id = $this->db->mysql_insert_id();
It is not working for me. I have used DB Driver as “mysql”. Then I have installed “mysqli” and changed the DB driver name in database.php like,
$db['default']['dbdriver'] = 'mysqli';Now it is working fine for me.