Skip to content

Instantly share code, notes, and snippets.

@mariuskubilius
Created May 6, 2014 22:19
Show Gist options
  • Select an option

  • Save mariuskubilius/2153921c7a91a74c8a24 to your computer and use it in GitHub Desktop.

Select an option

Save mariuskubilius/2153921c7a91a74c8a24 to your computer and use it in GitHub Desktop.

Revisions

  1. mariuskubilius created this gist May 6, 2014.
    14 changes: 14 additions & 0 deletions transactions.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    /**
    *Since Lithium uses PDO, you can just get the PDO object and call the beginTransaction() method.
    */

    $foo = app\models\Foo::create();
    $pdo = Connections::get('default')->connection;
    $pdo->beginTransaction();
    $foo->bar = 'Hello';
    $foo->save();
    $pdo->commit();
    /*
    * https://github.com/UnionOfRAD/lithium/issues/1004#issuecomment-23690165
    * http://www.php.net/manual/en/pdo.begintransaction.php
    */