add transitions to oc_db

This commit is contained in:
Robin Appelman 2011-07-31 20:24:53 +02:00
parent aff8bc62d2
commit 14f7daf53c
1 changed files with 33 additions and 0 deletions

View File

@ -361,4 +361,37 @@ class OC_DB {
self::dropTable($name); self::dropTable($name);
} }
} }
/**
* Start a transaction or set a savepoint.
* @param string $savePoint (optional) name of the savepoint to set
*/
public static function beginTransaction($savePoint=''){
if (!self::$DBConnection->supports('transactions')) {
return false;
}
if($savePoint && !self::$DBConnection->supports('savepoints')){
return false;
}
if($savePoint){
self::$DBConnection->beginTransaction($savePoint);
}else{
self::$DBConnection->beginTransaction();
}
}
/**
* Commit the database changes done during a transaction that is in progress or release a savepoint.
* @param string $savePoint (optional) name of the savepoint to commit
*/
public static function commit($savePoint=''){
if(!self::$DBConnection->inTransaction()){
return false;
}
if($savePoint){
self::$DBConnection->commit($savePoint);
}else{
self::$DBConnection->commit();
}
}
} }