If you use php, then you may be interested in https://github.com/Enelar/phpsql It supports mysql and pgsql and extends to other connectors.
function TransferMoney() { // Nested transaction code could not even know that he nested $trans3 = db::Begin(); if (!db::Query("--Withdraw money from user", [$uid, $amount], true)) return $trans3->Rollback(); db::Query("--Deposit money to system"); return $trans3->Commit(); } $trans = db::Begin(); db::Query("--Give item to user inventory"); $trans2 = $trans->Begin(); $trans2->Query("--Try some actions and then decide to rollback"); $trans2->Rollback(); // Commit or rollback depending on money transfer result return $trans->Finish(TransferMoney());
Offenso Jun 07 '14 at 15:58 2014-06-07 15:58
source share