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

timothy259856

Active member
Licensed customer
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!
 
PHP:
$dw->get('whatever_your_id_field_is_called');

Sorry but look like it cannot get the key of table, I have defined the key with name is "id" auto increasment but after call $dw->save(), it's return null when get the "id".
 
What is the name of your auto increment field in the database?
 
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.
 
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.
 
Back
Top Bottom