Zend Framework: How to retrieve the id of the last inserted row?

后端 未结 4 550
醉酒成梦
醉酒成梦 2021-01-17 13:06

I\'m inserting a new row into my database with this code:

$data = array(
    \'key\' => \'value\'
);
$this->getDbTable()->insert($data);
         


        
4条回答
  •  青春惊慌失措
    2021-01-17 13:30

    Did you try this ? This also works fine.

    //just after you call your insert($data) function .. use this
    $lastInsertId = $this->getAdapter()->lastInsertId();
    

提交回复
热议问题