]> source.dussan.org Git - nextcloud-server.git/commitdiff
add transitions to oc_db
authorRobin Appelman <icewind1991@gmail.com>
Sun, 31 Jul 2011 18:24:53 +0000 (20:24 +0200)
committerRobin Appelman <icewind1991@gmail.com>
Sun, 31 Jul 2011 18:24:53 +0000 (20:24 +0200)
lib/db.php

index 858db09b7643e8eab834aaf289067240678a179a..b7775b75ea45cac1c7afdbcd6e306b2e2b577bb4 100644 (file)
@@ -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();
+               }
+       }
 }