last insert id with zend db table abstract

巧了我就是萌 提交于 2019-12-22 01:40:46

问题


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


回答1:


try

$id = $tablemodel->insert($data);  
echo $id;



回答2:


$last_id = $tablemodel->getAdapter()->lastInsertId();



回答3:


you can use lastInsertId Method

echo 'last inserted id: ' . $db->lastInsertId();



回答4:


$insert_id = $this->db->getLastId() worked for me




回答5:


user after insert query

$this->dbAdapter->getDriver()->getLastGeneratedValue();


来源:https://stackoverflow.com/questions/4842064/last-insert-id-with-zend-db-table-abstract

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!