Added functions to retrieve the proper add and drop field SQL.

This commit is contained in:
stronk7 2006-09-12 22:15:00 +00:00
parent d256743c5b
commit 3ab2610037

View file

@ -453,6 +453,47 @@ class XMLDBgenerator {
return $results; return $results;
} }
/**
* Given one XMLDBTable and one XMLDBField, return the SQL statements needded to add the field to the table
*/
function getAddFieldSQL($xmldb_table, $xmldb_field) {
$results = array();
/// Get the quoted name of the table and field
$tablename = $this->getEncQuoted($this->prefix . $xmldb_table->getName());
/// Build the standard alter table add
$results[] = 'ALTER TABLE ' . $tablename . ' ADD ' . $this->getFieldSQL($xmldb_field);
/// If the DB has extra enum code
if ($this->enum_extra_code) {
/// If it's enum add the extra code
if ($xmldb_field->getEnum()) {
$results[] = 'ALTER TABLE ' . $tablename . ' ADD ' . $this->getEnumExtraSQL($xmldb_table, $xmldb_field);
}
}
return $results;
}
/**
* Given one XMLDBTable and one XMLDBField, return the SQL statements needded to drop the field from the table
*/
function getDropFieldSQL($xmldb_table, $xmldb_field) {
$results = array();
/// Get the quoted name of the table and field
$tablename = $this->getEncQuoted($this->prefix . $xmldb_table->getName());
$fieldname = $this->getEncQuoted($xmldb_field->getName());
/// Build the standard alter table drop
$results[] = 'ALTER TABLE ' . $tablename . ' DROP COLUMN ' . $fieldname;
return $results;
}
/** /**
* Given three strings (table name, list of fields (comma separated) and suffix), create the proper object name * Given three strings (table name, list of fields (comma separated) and suffix), create the proper object name
* quoting it if necessary * quoting it if necessary