]> git.mjollnir.org Git - moodle.git/commitdiff
Added to the generators the ability of prevent adding prefix for some tables.
authorstronk7 <stronk7>
Tue, 5 Sep 2006 17:17:49 +0000 (17:17 +0000)
committerstronk7 <stronk7>
Tue, 5 Sep 2006 17:17:49 +0000 (17:17 +0000)
(needed by adodb_logsql)

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

index 85228a9d92a443645280c5b5f74fb08683dd741e..39a301404730e7629bce9a8442576d1ea3435ad3 100644 (file)
@@ -83,7 +83,6 @@ class XMLDBgenerator {
 
     var $reserved_words; // List of reserved words (in order to quote them properly)
 
     /**
      * Creates one new XMLDBGenerator
      */
@@ -110,6 +109,15 @@ class XMLDBgenerator {
      */
     function getCreateTableSQL($xmldb_table) {
 
+        $tempprefix = '';
+    /// If the table needs to be created without prefix
+        if (in_array($xmldb_table->getName(), $this->getTablesWithoutPrefix())) {
+        /// Save current prefix to be restore later
+            $tempprefix = $this->prefix;
+        /// Empty prefix
+            $this->prefix = '';
+        }
+
         $results = array();  //Array where all the sentences will be stored
 
     /// Table header
@@ -238,6 +246,11 @@ class XMLDBgenerator {
             }
         }
 
+    /// Re-set the original prefix if it has changed
+        if ($tempprefix) {
+            $this->prefix = $tempprefix;
+        }
+
         return $results;
     }
 
@@ -609,12 +622,24 @@ class XMLDBgenerator {
      * You MUST provide the real list for each DB inside every XMLDB class
      */
     function getReservedWords() {
-    /// Some wel-know reserved words
+    /// Some well-know reserved words
         $reserved_words = array (
             'user', 'scale', 'type', 'comment', 'view', 'value', 'table', 'index', 'key', 'sequence', 'trigger'
         );  
         return $reserved_words;
     }
+
+    /**
+     * Returns an array of tables to be built without prefix (lowercase)
+     * It's enough to keep updated here this function.
+     */
+    function getTablesWithoutPrefix() {
+    /// Some well-known tables to be created without prefix
+        $tables = array (
+            'adodb_logsql'
+        );  
+        return $tables;
+    }
 }
 
 ?>