saveAll get all id save cakephp

To get all the IDs after saving data using the saveAll method in CakePHP, you can use the getInsertID() method. This method returns the last inserted ID for the current model.

Here's an example code snippet that demonstrates how to use saveAll and retrieve the IDs:

// Assuming you have a model called 'Example' with some data to save
$this->Example->saveAll($data);

// Get the last inserted ID
$lastInsertedId = $this->Example->getInsertID();

// You can now use $lastInsertedId as needed

By calling the getInsertID() method after saveAll, you can retrieve the ID of the last inserted record. This can be useful if you need to perform further operations or store the ID for later use.

Please note that the getInsertID() method only returns the ID of the last inserted record for the current model. If you have multiple models involved in the saveAll operation, you'll need to use the respective model's getInsertID() method to retrieve the IDs for each model.

I hope this helps! Let me know if you have any further questions.