I am focusing on a Magento module and have to know if you can roll back a number of model saves. Essentially, I've five models plus several from the module that I have to save one by one:


My issue is any time these models throw the best, I have to get into MySQL and by hand remove all of the rows which were saved. This is useless.

I am confident that Magento does not possess a rollback procedure will be able to access during my context. For instance, I looked in Mage_Core_Model_Abstract as well as in the save method, the rollback systems are protected.

So, my real question is, can there be some best practice for doing database transactions in Magento which i should know?

I have seen the next utilized in core code, also it appears like its precisely what you purchased.

$transactionSave = Mage::getModel('core/resource_transaction');

The core/resource_transaction object enables you to definitely add Magento objects, and execute a mass save money on them. Give that the try, and I'd like to hear how this may, or does not, meet your needs within the comments.