]> git.mjollnir.org Git - moodle.git/commitdiff
Now using ADOdb standard transactions. Some day, we should switch to
authorstronk7 <stronk7>
Fri, 22 Sep 2006 20:05:44 +0000 (20:05 +0000)
committerstronk7 <stronk7>
Fri, 22 Sep 2006 20:05:44 +0000 (20:05 +0000)
Smart Transactions (http://phplens.com/adodb/tutorial.smart.transactions.html)
as they autodetect errors and are nestable and easier to write

lib/dmllib.php

index 5c849aede5b531c278a23cc3879cd8de156e2eff..2c9fb5d61ffb1dba15ed2cca2b04a0ab123b93fe 100644 (file)
@@ -86,34 +86,57 @@ function execute_sql($command, $feedback=true) {
         return false;
     }
 }
+
 /**
 * on DBs that support it, switch to transaction mode and begin a transaction
-* you'll need to ensure you call commit_sql() or your changes *will* be lost
+* you'll need to ensure you call commit_sql() or your changes *will* be lost.
+*
+* Now using ADOdb standard transactions. Some day, we should switch to
+* Smart Transactions (http://phplens.com/adodb/tutorial.smart.transactions.html)
+* as they autodetect errors and are nestable and easier to write
+*
 * this is _very_ useful for massive updates
 */
 function begin_sql() {
-/// Completely general function - it just runs some SQL and reports success.
 
-    global $CFG;
-    if ($CFG->dbtype === 'postgres7') {
-        return execute_sql('BEGIN', false);
-    }
+    global $db;
+
+    $db->BeginTrans();
+
     return true;
 }
+
 /**
 * on DBs that support it, commit the transaction
+*
+* Now using ADOdb standard transactions. Some day, we should switch to
+* Smart Transactions (http://phplens.com/adodb/tutorial.smart.transactions.html)
+* as they autodetect errors and are nestable and easier to write
 */
-function rollback_sql() {
-/// Completely general function - it just runs some SQL and reports success.
+function commit_sql() {
+
+    global $db;
+
+    $db->CommitTrans();
 
-    global $CFG;
-    if ($CFG->dbtype === 'postgres7') {
-        return execute_sql('ROLLBACK', false);
-    }
     return true;
 }
 
+/**
+* on DBs that support it, rollback the transaction
+*
+* Now using ADOdb standard transactions. Some day, we should switch to
+* Smart Transactions (http://phplens.com/adodb/tutorial.smart.transactions.html)
+* as they autodetect errors and are nestable and easier to write
+*/
+function rollback_sql() {
+
+    global $db;
 
+    $db->RollbackTrans();
+
+    return true;
+}
 
 /**
  * returns db specific uppercase function
@@ -131,18 +154,6 @@ function db_lowercase() {
     return "lower";
 }
 
-/**
-* on DBs that support it, commit the transaction
-*/
-function commit_sql() {
-/// Completely general function - it just runs some SQL and reports success.
-
-    global $CFG;
-    if ($CFG->dbtype === 'postgres7') {
-        return execute_sql('COMMIT', false);
-    }
-    return true;
-}
 
 /**
  * Run an arbitrary sequence of semicolon-delimited SQL commands