summaryrefslogtreecommitdiffstats
path: root/lib/db.php
diff options
context:
space:
mode:
authorRobin Appelman <icewind1991@gmail.com>2011-07-31 20:24:53 +0200
committerRobin Appelman <icewind1991@gmail.com>2011-07-31 20:24:53 +0200
commit14f7daf53c90f14e8fa600926ae19b3e44320158 (patch)
tree59a8f3a901ef9821e67b7070907e7d39d4c99395 /lib/db.php
parentaff8bc62d26e1fc7555eb49a2f4a98f0c3d45c3f (diff)
downloadnextcloud-server-14f7daf53c90f14e8fa600926ae19b3e44320158.tar.gz
nextcloud-server-14f7daf53c90f14e8fa600926ae19b3e44320158.zip
add transitions to oc_db
Diffstat (limited to 'lib/db.php')
-rw-r--r--lib/db.php33
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/db.php b/lib/db.php
index 858db09b764..b7775b75ea4 100644
--- a/lib/db.php
+++ b/lib/db.php
@@ -361,4 +361,37 @@ class OC_DB {
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();
+ }
+ }
}