• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

How to get last insert id after call $dw->save();

#1
Hello guys!

When I execute an insert item to my table use $dw->save(); how can I get the id which created after call save()?

I know that Zend support the $db->lastInsertId() but where to do this? Do I need do anything in the DataWriter?

Thank you!
 

Chris D

XenForo developer
Staff member
#9
Are you sure the $dw->save(); actually worked without errors? You're not forcing the errors to be silent? Can you see the data in the database at that point?

This approach is used throughout XenForo to get the data that's just been saved to the database.
 
#10
Are you sure the $dw->save(); actually worked without errors? You're not forcing the errors to be silent? Can you see the data in the database at that point?

This approach is used throughout XenForo to get the data that's just been saved to the database.
Yes, I do the check, I saw the data was insert in database. I can get others field but not for the key.