Skip to content

Commit

Permalink
Some adjustments to be able to get names without prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
stronk7 committed Oct 2, 2006
1 parent 6c02f04 commit 0e204a1
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions lib/xmldb/classes/generators/XMLDBGenerator.class.php
Expand Up @@ -495,7 +495,7 @@ function getRenameTableSQL($xmldb_table, $newname) {

$results[] = $rename;

/// TODO, call to getRenameTableExtraSQL() if $rename_table_extra_code is enabled. It will add sequence regeneration code.
/// Call to getRenameTableExtraSQL() if $rename_table_extra_code is enabled. It will add sequence regeneration code.
if ($this->rename_table_extra_code) {
$extra_sentences = $this->getRenameTableExtraSQL($xmldb_table, $newname);
$results = array_merge($results, $extra_sentences);
Expand Down Expand Up @@ -874,7 +874,7 @@ function getRenameIndexSQL($xmldb_table, $xmldb_index, $newname) {
* Given three strings (table name, list of fields (comma separated) and suffix), create the proper object name
* quoting it if necessary
*/
function getNameForObject($tablename, $fields, $suffix) {
function getNameForObject($tablename, $fields, $suffix='') {

$name = '';

Expand Down Expand Up @@ -905,7 +905,10 @@ function getNameForObject($tablename, $fields, $suffix) {
$name = substr(trim($name), 0, $this->names_max_length - 1 - strlen($suffix)); //Max names_max_length

/// Add the suffix
$namewithsuffix = $name . '_' . $suffix;
$namewithsuffix = $name;
if ($suffix) {
$namewithsuffix = $namewithsuffix . '_' . $suffix;
}

/// If the calculated name is in the cache, let's modify if
if (in_array($namewithsuffix, $used_names)) {
Expand All @@ -917,11 +920,17 @@ function getNameForObject($tablename, $fields, $suffix) {
} else {
$newname = substr($name, 0, strlen($name)-1) . $counter;
}
$newnamewithsuffix = $newname . '_' . $suffix;
$newnamewithsuffix = $newname;
if ($suffix) {
$newnamewithsuffix = $newnamewithsuffix . '_' . $suffix;
}
/// Now iterate until not used name is found, incrementing the counter
while (in_array($newnamewithsuffix, $used_names)) {
$newname = substr($name, 0, strlen($newname)-1) . $counter;
$newnamewithsuffix = $newname . '_' . $suffix;
$newnamewithsuffix = $newname;
if ($suffix) {
$newnamewithsuffix = $newnamewithsuffix . '_' . $suffix;
}
$counter++;
}
$namewithsuffix = $newnamewithsuffix;
Expand Down

0 comments on commit 0e204a1

Please sign in to comment.