开发者

last insert id with zend db table abstract

开发者 https://www.devze.com 2023-02-07 17:52 出处:网络
variable $tablemodel in an instance of a model which extends Zend_Db_Table_Abstract, if i do $tablemodel->insert($data)

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

0

精彩评论

暂无评论...
验证码 换一张
取 消