variable $tablemodel
in an instance of a model which extends Zend_Db_Table_Abstract
, if i do
变量$ tablemodel在扩展Zend_Db_Table_Abstract的模型实例中,如果我这样做的话
$tablemodel->insert($data)
to insert data. Is there any method or property to get last insert id?
插入数据。是否有任何方法或属性来获取最后一个插入ID?
regards
问候
5 个解决方案
#1
33
try
尝试
$id = $tablemodel->insert($data);
echo $id;
#2
26
$last_id = $tablemodel->getAdapter()->lastInsertId();
#3
9
you can use lastInsertId Method
你可以使用lastInsertId方法
echo 'last inserted id: ' . $db->lastInsertId();
#4
1
$insert_id = $this->db->getLastId()
worked for me
$ insert_id = $ this-> db-> getLastId()为我工作
#5
0
user after insert query
插入查询后的用户
$this->dbAdapter->getDriver()->getLastGeneratedValue();
#1
33
try
尝试
$id = $tablemodel->insert($data);
echo $id;
#2
26
$last_id = $tablemodel->getAdapter()->lastInsertId();
#3
9
you can use lastInsertId Method
你可以使用lastInsertId方法
echo 'last inserted id: ' . $db->lastInsertId();
#4
1
$insert_id = $this->db->getLastId()
worked for me
$ insert_id = $ this-> db-> getLastId()为我工作
#5
0
user after insert query
插入查询后的用户
$this->dbAdapter->getDriver()->getLastGeneratedValue();