Write a custom function to fetch last insert id in zend framework
Answer / Sandeep Aswal
In Zend Framework, you can use the `Zend_Db_Adapter` class to create a database adapter and write a custom function to fetch the last inserted ID.nHere's an example of how to do it:nn```phpnpublic function getLastInsertId() {n $lastInsertId = null;n try {n $this->getDb()->lastInsertId($this->_name);n $lastInsertId = $this->getDb()->getLastGeneratedValue("ID");n } catch (Exception $e) {n // Handle the exception heren }n return $lastInsertId;n}n```nThis function assumes that you have a database table named `$this->_name` and the primary key is named `ID`.
| Is This Answer Correct ? | 0 Yes | 0 No |
How to set up 2 navigations in zend framework 2?
Do you know what is zend engine?
How do you define the library path in zend ?
What are the difference between zend_registry and zend_session?
What do you mean by service manager in zend framework 2?
How to log out users using facebook connect in php and zend?
How to include css and js from the controller in the zend framework?
What is event manager in zend framework?
How can I detect if an optional file has been uploaded?
Explain the difference between zend_registry and zend_session in zend?
What is zend engine in php?
What do you know about zend layout?