Using saveAll()
to save multiple records in CakePHP, I am able to save them successfully in a table. But the problem arises while retrieving the IDs of those saved rows. LastInsertID()
returns only a single last ID here. How can I get all the last inserted IDs which I have inserted using saveAll()
?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
afterSave function is called after each individual save in a saveAll execution, so you could do: In your AppModel
You can place this code into any model and it should work fine. Then to return the IDs after the saveAll in your controller, you would do so like this:
Hope it helps