Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

last insert id with zend db table abstract

variable $tablemodel in an instance of a model which extends Zend_Db_Table_Abstract, if i do

$tablemodel->insert($data) 

to insert data. Is there any method or property to get last insert id?

regards

like image 572
Santosh Linkha Avatar asked Jan 30 '11 09:01

Santosh Linkha


People also ask

How can I get last insert ID in PDO?

You can get the id of the last transaction by running lastInsertId() method on the connection object($conn).

How do I find the last inserted record?

If you are AUTO_INCREMENT with column, then you can use last_insert_id() method. This method gets the ID of the last inserted record in MySQL. Insert some records in the table using insert command.

What is last insert ID?

The LAST_INSERT_ID() function returns the AUTO_INCREMENT id of the last row that has been inserted or updated in a table.


2 Answers

try

$id = $tablemodel->insert($data);   echo $id; 
like image 79
Haim Evgi Avatar answered Sep 19 '22 09:09

Haim Evgi


$last_id = $tablemodel->getAdapter()->lastInsertId(); 
like image 23
Art3mk4 Avatar answered Sep 20 '22 09:09

Art3mk4