Skip to content

Commit

Permalink
Initial, unfinished, not working, simple version of rename_table gene…
Browse files Browse the repository at this point in the history
…rator.

More coming soon, but I needed it in CVS now!
  • Loading branch information
stronk7 committed Sep 6, 2006
1 parent 386c23c commit d05babe
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions lib/xmldb/classes/generators/XMLDBGenerator.class.php
Expand Up @@ -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

Expand Down Expand Up @@ -400,6 +404,24 @@ function getDefaultClause ($xmldb_field) {
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
Expand Down Expand Up @@ -617,6 +639,13 @@ function getCommentSQL ($xmldb_table) {
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
Expand Down

0 comments on commit d05babe

Please sign in to comment.