]> git.mjollnir.org Git - moodle.git/commitdiff
Now we are able to generate all the module SQL (any RDBMS) with one
authorstronk7 <stronk7>
Thu, 17 Aug 2006 00:16:34 +0000 (00:16 +0000)
committerstronk7 <stronk7>
Thu, 17 Aug 2006 00:16:34 +0000 (00:16 +0000)
simple function call (final inserts are missing yet)

lib/xmldb/classes/XMLDBStructure.class.php
lib/xmldb/classes/generators/XMLDBGenerator.class.php

index 73eea8cc0f4164c1114ef023c6818a7a7a505981..985c3cbc83769b2116cc8ea9946a1d07294fa5da 100644 (file)
@@ -692,6 +692,25 @@ class XMLDBStructure extends XMLDBObject {
             return false;
         }
     }
+
+    /** 
+     * This function will return the SQL code needed to create the table for the specified DB and
+     * prefix. Just one simple wrapper over generators.
+     */
+    function getCreateStructureSQL ($dbtype, $prefix) {
+
+        $sqltext = '';
+        
+        $classname = 'XMLDB' . $dbtype;
+        $generator = new $classname();
+        $generator->setPrefix($prefix);
+        if ($tables = $this->getTables()) {
+            foreach ($tables as $table) {
+                $sqltext .= $generator->getCreateTableSQL($table) . "\n\n";
+            }
+        }
+        return $sqltext;
+    }
 }
 
 ?>
index 7bcc0c263436b52ca7aa2045636f1f9b38e416b0..56c415a9a7073ef4b4fafdde0719bc4cd7e6fedb 100644 (file)
@@ -277,6 +277,7 @@ class XMLDBgenerator {
             }
         }
     /// Calculate the not null clause
+        $notnull = '';
         if ($xmldb_field->getNotNull()) {
             $notnull = ' NOT NULL';
         }