]> git.mjollnir.org Git - moodle.git/commitdiff
First implementation of the create_table() function. Simple.
authorstronk7 <stronk7>
Sat, 2 Sep 2006 23:48:02 +0000 (23:48 +0000)
committerstronk7 <stronk7>
Sat, 2 Sep 2006 23:48:02 +0000 (23:48 +0000)
lib/ddllib.php

index 738439cfa4b32e1b266b0face328ab3bed9451e5..b05a6a64dc95eb3b8e210f45264a13a98d85a89b 100644 (file)
@@ -272,13 +272,31 @@ function install_from_xmldb_file($file) {
         return false;
     }
 
-    foreach($sqlarr as $sql) {
-        if (!execute_sql($sql)) {
-            $status = false;  // Allow to continue to mimic old behaviour
-        }                     // perhaps it would be better to exit false
+    return execute_sql_arr($sqlarr);
+}
+
+/**
+ * This function will create the table passed as argument with all its
+ * fields/keys/indexes/sequences, everything based in the XMLDB object
+ *
+ * @param XMLDBtable table object containing all the table info
+ * @return boolean true on success, false on error
+ */
+function create_table($table) {
+
+    global $CFG, $db;
+
+    $status = true;
+
+    if (strtolower(get_class($table)) != 'xmldbtable') {
+        return false;
+    }
+
+    if(!$sqlarr = $table->getCreateTableSQL($CFG->dbtype, $CFG->prefix, false)) {
+        return false;
     }
 
-    return $status;
+    return execute_sql_arr($sqlarr);
 }
 
 ?>