]> git.mjollnir.org Git - moodle.git/commitdiff
Added rename_field() support for MySQL
authorstronk7 <stronk7>
Sun, 1 Oct 2006 22:44:39 +0000 (22:44 +0000)
committerstronk7 <stronk7>
Sun, 1 Oct 2006 22:44:39 +0000 (22:44 +0000)
lib/xmldb/classes/generators/mysql/mysql.class.php

index 7d3547f4d64fafcb7dcbde840a248f5af8bf5211..54251f977bd05beece5945314e4355dbab3114ac 100644 (file)
@@ -194,6 +194,24 @@ class XMLDBmysql extends XMLDBGenerator {
         return $this->getAlterFieldSQL($xmldb_table, $xmldb_field);
     }
 
+    /**
+     * Given one correct XMLDBField and the new name, returns the SQL statements
+     * to rename it (inside one array)
+     * MySQL is pretty diferent from the standard to justify this oveloading
+     */
+    function getRenameFieldSQL($xmldb_table, $xmldb_field, $newname) {
+
+        $results = array();  //Array where all the sentences will be stored
+
+    /// Change the name of the field to perform the change
+        $xmldb_field->setName($xmldb_field->getName() . ' ' . $newname);
+
+        $results[] = 'ALTER TABLE ' . $this->getTableName($xmldb_table) . ' CHANGE ' .
+                     $this->getFieldSQL($xmldb_field);
+
+        return $results;
+    }
+
     /**
      * Given one XMLDBTable and one XMLDBField, return the SQL statements needded to drop its default 
      * (usually invoked from getModifyDefaultSQL()