]> git.mjollnir.org Git - moodle.git/commitdiff
Now the "AFTER" clause is supported by add_field()
authorstronk7 <stronk7>
Tue, 12 Sep 2006 22:58:04 +0000 (22:58 +0000)
committerstronk7 <stronk7>
Tue, 12 Sep 2006 22:58:04 +0000 (22:58 +0000)
lib/xmldb/classes/generators/XMLDBGenerator.class.php
lib/xmldb/classes/generators/mysql/mysql.class.php

index 7c7b6c75531268d81d61f7d813786cbfea442435..b15278aead13a3b05fff69a6d4e77c14acd8fd97 100644 (file)
@@ -72,6 +72,8 @@ class XMLDBgenerator {
 
     var $add_table_comments  = true;  // Does the generator need to add code for table comments
 
+    var $add_after_clause = false; // Does the generator need to add the after clause for fields
+
     var $prefix_on_names = true; //Does the generator need to prepend the prefix to all the key/index/sequence/trigger/check names
 
     var $names_max_length = 30; //Max length for key/index/sequence/trigger/check names (keep 30 for all!)
@@ -137,7 +139,8 @@ class XMLDBgenerator {
         }
     /// Add the fields, separated by commas
         foreach ($xmldb_fields as $xmldb_field) {
-            $table .= "\n    " . $this->getFieldSQL($xmldb_field) . ',';
+            $table .= "\n    " . $this->getFieldSQL($xmldb_field);
+            $table .= ',';
         }
     /// Add the keys, separated by commas
         if ($xmldb_keys = $xmldb_table->getKeys()) {
@@ -464,7 +467,12 @@ class XMLDBgenerator {
         $tablename = $this->getEncQuoted($this->prefix . $xmldb_table->getName());
 
     /// Build the standard alter table add
-        $results[] = 'ALTER TABLE ' . $tablename . ' ADD ' . $this->getFieldSQL($xmldb_field);
+        $altertable = 'ALTER TABLE ' . $tablename . ' ADD ' . $this->getFieldSQL($xmldb_field);
+    /// Add the after clause if necesary
+        if ($this->add_after_clause && $xmldb_field->getPrevious()) {
+            $altertable .= ' after ' . $this->getEncQuoted($xmldb_field->getPrevious());
+        }
+        $results[] = $altertable;
 
     /// If the DB has extra enum code
         if ($this->enum_extra_code) {
index 0b0572db3142538cd97d83109d4a99c30905b10d..936ec7a3dcdb3b40c69c34ffc55fcd3268e56f79 100644 (file)
@@ -48,6 +48,8 @@ class XMLDBmysql extends XMLDBGenerator {
 
     var $enum_extra_code = false; //Does the generator need to add extra code to generate code for the enums in the table
 
+    var $add_after_clause = true; // Does the generator need to add the after clause for fields
+
     var $concat_character = null; //Characters to be used as concatenation operator. If not defined
                                   //MySQL CONCAT function will be use