Saving data for several models at once could lead to orphaned data if some validation breaks along the way. It's always good practice to use atomic save operations when related data needs to make it to the database together.
CakePHP provides the saveAssociated()
, saveMany()
, and saveAll()
model methods to store your data using an atomic operation, but sometimes, you'll want to use a database transaction to manage it. Find more details on these methods at http://book.cakephp.org/2.0/en/models/saving-your-data.html#model-savemany-array-data-null-array-options-array.