Take a look at application / code / kernel /Mage/Core/Model/Resource/Transaction.php
This model allows you to add other models as objects in a transaction. During saving, call $object->save() for each added object. If something fails, it calls $object->getResource()->rollBack() for each object. You can also add commit callbacks via addCommitCallback(array($object, 'callbackFunctionName')) .
If you need to delete a transaction, call $transaction->delete() instead of $transaction->save() . In this case, instead of $object->save() $object->delete() is called to call the object $object->delete() .
Example:
try { $transaction = Mage::getModel('core/resource_transaction') ->addObject(Mage::getModel('modulename/table1')) ->addObject(Mage::getModel('modulename/table2')) ->addObject(Mage::getModel('modulename/table3')); $transaction->save(); } catch (Exception $e) { echo $e->getMessage(); }
source share