The method failTrans()
forces a roll back of a smart transaction. The method can be called anywhere inside a transaction scope, but the rollback actually occurs at the point where completeTrans()
is invoked.
/* * Assume database connection */ $db->startTrans(); /* * some reason to rollback transaction */ $db->failTrans(); /* * Lots more code inside the transaction scope */ $db->completeTrans(); //<---- at this point, the rollback is invoked