Initial, unfinished, not working, simple version of rename_table generator.

More coming soon, but I needed it in CVS now!
This commit is contained in:
stronk7
2006-09-06 23:04:13 +00:00
parent 386c23c9da
commit d05babe913
@@ -78,6 +78,10 @@ class XMLDBgenerator {
var $concat_character = '||'; //Characters to be used as concatenation operator. If not defined
//MySQL CONCAT function will be used
var $rename_table_sql = 'ALTER TABLE OLDNAME RENAME TO NEWNAME'; //SQL sentence to rename one table, both
//OLDNAME and NEWNAME are dinamically replaced
var $rename_table_extra_code = false; //Does the generatos need to add code after table renaming
var $prefix; // Prefix to be used for all the DB objects
@@ -400,6 +404,24 @@ class XMLDBgenerator {
return $default;
}
/**
* Given one correct XMLDBTable and the new name, returns the SQL statements
* to rename it (inside one array)
*/
function getRenameTableSQL($xmldb_table, $newname) {
$results = array(); //Array where all the sentences will be stored
$rename = str_replace('OLDNAME', $this->getEncQuoted($this->prefix . $xmldb_table->getName), $rename_table_sql);
$rename = str_replace('NEWNAME', $this->getEncQuoted($this->prefix . $newname), $rename_table_sql);
$results[] = $rename;
/// TODO, call to getRenameTableExtraSQL() if $rename_table_extra_code is enabled. It will add sequence regeneration code.
return $results;
}
/**
* Given three strings (table name, list of fields (comma separated) and suffix), create the proper object name
* quoting it if necessary
@@ -617,6 +639,13 @@ class XMLDBgenerator {
return 'Code for table comment goes to getCommentSQL(). Can be disabled with add_table_comments=false;';
}
/**
* Returns the code (array of statements) needed to execute extra statements on table rename
*/
function getRenameTableExtraSQL ($xmldb_table) {
return 'Code for table comment goes to getCommentSQL(). Can be disabled with add_table_comments=false;';
}
/**
* Returns an array of reserved words (lowercase) for this DB
* You MUST provide the real list for each DB inside every XMLDB class