How to Get Last inserted ID in Zend Framework 2?

We often need last inserted ID for different reasons(for example when you need to store foreign key), Immediately after a record has been inserted into the database, you can get the id that was auto incremented(primary Key).

After Inserting data into table , we can get Inserted ID the following ways

Using Abstract Table Gateway Property :

The ZendDbTableGatewayAbstractTableGateway specifies a $lastInsertValue Property

Using Abstract Table Gateway Method :

The ZendDbTableGatewayAbstractTableGateway specifies a getLastInsertValue() method

Using Abstract Table Gateway Method :

The ZendDbAdapterDriverDriverInterface specifies a getLastGeneratedValue() method

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.

0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
DMCA.com Protection Status
0
Would love your thoughts, please comment.x
()
x