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
You can get the id of the last transaction by running lastInsertId() method on the connection object($conn).
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.
The LAST_INSERT_ID() function returns the AUTO_INCREMENT id of the last row that has been inserted or updated in a table.
try
$id = $tablemodel->insert($data); echo $id;
$last_id = $tablemodel->getAdapter()->lastInsertId();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With