Skip to content

Instantly share code, notes, and snippets.

@thecodedrift
Created August 17, 2012 22:14
Show Gist options
  • Select an option

  • Save thecodedrift/3383208 to your computer and use it in GitHub Desktop.

Select an option

Save thecodedrift/3383208 to your computer and use it in GitHub Desktop.
PHP transaction managers
<?php
$btm = new BankTransactionManager($transaction);
// create entry (Account, Entry Type)
$e = $btm->createEntry("Gold.Gold");
$e->setUserId($user_id);
$e->addGold($gold_amount);
$btm->addEntry($e);
$e = $btm->createEntry("ServerGold.Gold");
$e->setUserId(ENTITY_SERVER);
$e->subtractGold($gold_amount);
$btm->addEntry($e);
try {
$btm->execute();
}
catch (Exception $e) {
throw $e;
}
?>
SELECT "columns" FROM "table" WHERE "criteria" FOR UPDATE;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment