From: stronk7 Date: Thu, 17 Aug 2006 00:16:34 +0000 (+0000) Subject: Now we are able to generate all the module SQL (any RDBMS) with one X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=848caec8c2560c2b3aac6fd7e09efb7d9c920d76;p=moodle.git Now we are able to generate all the module SQL (any RDBMS) with one simple function call (final inserts are missing yet) --- diff --git a/lib/xmldb/classes/XMLDBStructure.class.php b/lib/xmldb/classes/XMLDBStructure.class.php index 73eea8cc0f..985c3cbc83 100644 --- a/lib/xmldb/classes/XMLDBStructure.class.php +++ b/lib/xmldb/classes/XMLDBStructure.class.php @@ -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; + } } ?> diff --git a/lib/xmldb/classes/generators/XMLDBGenerator.class.php b/lib/xmldb/classes/generators/XMLDBGenerator.class.php index 7bcc0c2634..56c415a9a7 100644 --- a/lib/xmldb/classes/generators/XMLDBGenerator.class.php +++ b/lib/xmldb/classes/generators/XMLDBGenerator.class.php @@ -277,6 +277,7 @@ class XMLDBgenerator { } } /// Calculate the not null clause + $notnull = ''; if ($xmldb_field->getNotNull()) { $notnull = ' NOT NULL'; }