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

According to the API documentation for the Zend_Db_Table_Abstract insert() method.

According to the API documentation for the Zend_Db_Table_Abstract insert() method: Inserts a new row. Return: The primary key of the row inserted. Access: public So: $lastInsertId = $this->getDbTable()->insert($data).

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

One gotcha. When calling $this->getDbTable()->insert($data); you have to make sure $data include the "primary key" of your table. For example, id=null if it's auto-increment.

Otherwise, insert() will not return the last inserted ID.

According to here, make sure that the table has a primary key: //This will return the primary key of the last inserted row $db->insert('', $data); return $db->lastInsertId().

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions