]> git.mjollnir.org Git - moodle.git/commitdiff
Merge from MOODLE_14_STABLE: moodle--eduforge--1.3.3--patch-207(partial) + moodle...
authormjollnir_ <mjollnir_>
Wed, 17 Nov 2004 05:31:21 +0000 (05:31 +0000)
committermjollnir_ <mjollnir_>
Wed, 17 Nov 2004 05:31:21 +0000 (05:31 +0000)
course/category.php
lib/datalib.php

index 4f1c13b006b19404d21244dde7e4cd6120a225e7..70f93fa119a02d5511b2e93dcc3eecdd92194833 100644 (file)
             }
             if ($swapcourse and $movecourse) {        // Renumber everything for robustness
                 $count=0;
+                begin_sql();
                 foreach ($courses as $course) {
                     $count++;
                     if ($course->id == $swapcourse->id) {
                         notify("Could not update that course!");
                     }
                 }
+                commit_sql();
             }
         }
 
index 70d96479f2d92a28a72e1f3e2b4ac0738a0bcdf2..10951a6c541e899610120146411e79209b5ea8b9 100644 (file)
@@ -58,6 +58,32 @@ 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
+* 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);
+    }
+    return true;
+}
+/**
+* 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