Skip to content

wakeless/transaction_pdo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

TransactionPDO is a wrapper for the PDO object in PHP.

It adds the ability to nest transactions as well as a nice syntax for writing transactions with a closure syntax.

Usage

$db = new TransactionPDO($connectDSN);

$success = $db->transaction(function() use ($db) {
  $db->exec("Insert or whatever");
  if($rollback) {
    return false; //rollback
  } elseif($exception) {
    throw new Exception("This will rollback and thrown outside");
  } else {
    return true; //commit
  }
});

if($success) { 
  //committed 
} else {
  //rollback
}

Thanks

Thanks go to Kenny Millington for his initial implementation here: http://www.kennynet.co.uk/2008/12/02/php-pdo-nested-transactions/

License

GNU General Public License v3.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages