From 848caec8c2560c2b3aac6fd7e09efb7d9c920d76 Mon Sep 17 00:00:00 2001 From: stronk7 Date: Thu, 17 Aug 2006 00:16:34 +0000 Subject: [PATCH] Now we are able to generate all the module SQL (any RDBMS) with one simple function call (final inserts are missing yet) --- lib/xmldb/classes/XMLDBStructure.class.php | 19 +++++++++++++++++++ .../generators/XMLDBGenerator.class.php | 1 + 2 files changed, 20 insertions(+) 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'; } -- 2.39.5