Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

$this->db->insert_id() not working in mysql codeigniter

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?

like image 912
Ananth Duari Avatar asked Aug 04 '11 13:08

Ananth Duari


1 Answers

CodeIgniter's insert_id() will only return an ID of an insert(). Unless you are executing something like $this->db->insert('table', $data); before calling the function it will not be able to return an ID.

like image 130
Chris Schmitz Avatar answered Oct 09 '22 11:10

Chris Schmitz