Skip to content

Instantly share code, notes, and snippets.

@mariuskubilius
Created May 6, 2014 22:19
Show Gist options
  • Save mariuskubilius/2153921c7a91a74c8a24 to your computer and use it in GitHub Desktop.
Save mariuskubilius/2153921c7a91a74c8a24 to your computer and use it in GitHub Desktop.
Transaction support in lithium.
/**
*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
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment