When an action requires multiple SQL queries that must all succeed together (such as creating an order and deducting wallet balance), wrap them in a Transaction. If anything throws an exception, rollBack() undoes every partial change automatically.
ADVERTISEMENT