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 ther开发者_运维知识库e any method or property to get last insert id?
regards
try
$id = $tablemodel->insert($data);
echo $id;
$last_id = $tablemodel->getAdapter()->lastInsertId();
you can use lastInsertId Method
echo 'last inserted id: ' . $db->lastInsertId();
use after insert query
$this->dbAdapter->getDriver()->getLastGeneratedValue();
$insert_id = $this->db->getLastId()
worked for me
精彩评论