Is it possible to rollback the entire transaction from within the various Doctrine_Record ‘post’ hooks? I.E. from within postInsert(), postUpdate(), postSave() etc
I am using Doctrine 1.2 and from the documentation and the API it is not clear how to do this.
Looking through the docs it’s clear Doctrine_Event is your best starting point, since that’s passed into the event handlers. Essentially you’ll have to get a hold of the Doctrine_Connection object (through getInvoker()) and then try to call rollback on it.
Only trouble is getInvoker returns one of several types of objects and I’m unsure if they all support a rollback method, so you may need some conditional logic to determine if you can even rollback from all of them and how to do so for the different cases.
The documentation shows how to begin, commit and rollback through the a Doctrine_Connection so that should be the easiest starting point. So a listener would look something like: