开发者

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

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜