From: stronk7 Date: Sun, 1 Oct 2006 22:44:39 +0000 (+0000) Subject: Added rename_field() support for MySQL X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=b5d61bfd9d7f924acc5dec9ddbe1fcaad08e85a9;p=moodle.git Added rename_field() support for MySQL --- diff --git a/lib/xmldb/classes/generators/mysql/mysql.class.php b/lib/xmldb/classes/generators/mysql/mysql.class.php index 7d3547f4d6..54251f977b 100644 --- a/lib/xmldb/classes/generators/mysql/mysql.class.php +++ b/lib/xmldb/classes/generators/mysql/mysql.class.php @@ -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()