Skip to content

Instantly share code, notes, and snippets.

@Ikke
Last active December 25, 2015 10:29
Show Gist options
  • Save Ikke/6962286 to your computer and use it in GitHub Desktop.
Save Ikke/6962286 to your computer and use it in GitHub Desktop.
Transaction wrapper (pseudocode)
<?php
class Transaction
{
protected $db;
public function __construct($db)
{
$this->db = $db
}
public function execute(Command $command)
{
$this->db->start_transaction();
try
{
$command->execute();
}
catch (Exception $ex) { //Catch an appropiate exception here
$this->db->roll_back();
return;
}
$db->commit()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment