return $results;
}
+ /**
+ * This function will return the SQL code needed to modify the enum of one field in the table for the specified DB and
+ * prefix. Just one simple wrapper over generators.
+ */
+ function getModifyEnumSQL ($dbtype, $prefix, $xmldb_field, $statement_end=true) {
+
+ $results = array();
+
+ $classname = 'XMLDB' . $dbtype;
+ $generator = new $classname();
+ $generator->setPrefix($prefix);
+ $results = $generator->getModifyEnumSQL($this, $xmldb_field);
+ if ($statement_end) {
+ $results = $generator->getEndedStatements($results);
+ }
+ return $results;
+ }
+
/**
* This function will return the SQL code needed to modify the default of one field in the table for the specified DB and
* prefix. Just one simple wrapper over generators.
/// Add the after clause if necesary
if ($this->add_after_clause && $xmldb_field->getPrevious()) {
- $altertable .= ' after ' . $this->getEncQuoted($xmldb_field->getPrevious());
+ $alter .= ' after ' . $this->getEncQuoted($xmldb_field->getPrevious());
+ }
+
+ return $results;
+ }
+
+ /**
+ * Given one XMLDBTable and one XMLDBField, return the SQL statements needded to modify the enum of the field in the table
+ */
+ function getModifyEnumSQL($xmldb_table, $xmldb_field) {
+
+ $results = array();
+
+ /// Get the quoted name of the table and field
+ $tablename = $this->getTableName($xmldb_table);
+ $fieldname = $this->getEncQuoted($xmldb_field->getName());
+
+ /// Decide if we are going to create or to drop the enum (based exclusively in the values passed!)
+ if (!$xmldb_field->getEnum()) {
+ $results = $this->getDropEnumSQL($xmldb_table, $xmldb_field); //Drop
+ } else {
+ $results = $this->getCreateEnumSQL($xmldb_table, $xmldb_field); //Create/modify
}
return $results;
return array('Code for table drop goes to getDropTableExtraSQL(). Can be disabled with drop_table_extra_code=false;');
}
+ /**
+ * Given one XMLDBTable and one XMLDBField, return the SQL statements needded to drop its enum
+ * (usually invoked from getModifyEnumSQL()
+ */
+ function getDropEnumSQL($xmldb_table, $xmldb_field) {
+ return array('Code to drop one enum goes to getDropEnumSQL()');
+ }
+
+ /**
+ * Given one XMLDBTable and one XMLDBField, return the SQL statements needded to add its enum
+ * (usually invoked from getModifyEnumSQL()
+ */
+ function getCreateEnumSQL($xmldb_table, $xmldb_field) {
+ return array('Code to create one enum goes to getCreateEnumSQL()');
+ }
+
/**
* Given one XMLDBTable and one XMLDBField, return the SQL statements needded to drop its default
* (usually invoked from getModifyDefaultSQL()
* (usually invoked from getModifyDefaultSQL()
*/
function getCreateDefaultSQL($xmldb_table, $xmldb_field) {
- return array('Code to create one default goes to getCreate()');
+ return array('Code to create one default goes to getCreateDefaultSQL()');
}
/**
return $results;
}
+ /**
+ * Given one XMLDBTable and one XMLDBField, return the SQL statements needded to create its enum
+ * (usually invoked from getModifyEnumSQL()
+ */
+ function getCreateEnumSQL($xmldb_table, $xmldb_field) {
+ /// All we have to do is to create the check constraint
+ return array('ALTER TABLE ' . $this->getTableName($xmldb_table) .
+ ' ADD ' . $this->getEnumExtraSQL($xmldb_table, $xmldb_field));
+ }
+
+ /**
+ * Given one XMLDBTable and one XMLDBField, return the SQL statements needded to drop its enum
+ * (usually invoked from getModifyEnumSQL()
+ */
+ function getDropEnumSQL($xmldb_table, $xmldb_field) {
+ /// All we have to do is to drop the check constraint
+ return array('ALTER TABLE ' . $this->getTableName($xmldb_table) .
+ ' DROP CONSTRAINT ' . $this->getNameForObject($xmldb_table->getName(), $xmldb_field->getName(), 'ck'));
+ }
+
/**
* Given one XMLDBTable and one XMLDBField, return the SQL statements needded to create its default
* (usually invoked from getModifyDefaultSQL()
return $dbtype;
}
+ /**
+ * Given one XMLDBTable and one XMLDBField, return the SQL statements needded to create its enum
+ * (usually invoked from getModifyEnumSQL()
+ */
+ function getCreateEnumSQL($xmldb_table, $xmldb_field) {
+ /// For MySQL, just alter the field
+ return $this->getAlterFieldSQL($xmldb_table, $xmldb_field);
+ }
+
+ /**
+ * Given one XMLDBTable and one XMLDBField, return the SQL statements needded to drop its enum
+ * (usually invoked from getModifyEnumSQL()
+ */
+ function getDropEnumSQL($xmldb_table, $xmldb_field) {
+ /// For MySQL, just alter the field
+ return $this->getAlterFieldSQL($xmldb_table, $xmldb_field);
+ }
+
/**
* Given one XMLDBTable and one XMLDBField, return the SQL statements needded to create its default
* (usually invoked from getModifyDefaultSQL()
return $results;
}
+ /**
+ * Given one XMLDBTable and one XMLDBField, return the SQL statements needded to create its enum
+ * (usually invoked from getModifyEnumSQL()
+ */
+ function getCreateEnumSQL($xmldb_table, $xmldb_field) {
+ /// All we have to do is to create the check constraint
+ return array('ALTER TABLE ' . $this->getTableName($xmldb_table) .
+ ' ADD ' . $this->getEnumExtraSQL($xmldb_table, $xmldb_field));
+ }
+
+ /**
+ * Given one XMLDBTable and one XMLDBField, return the SQL statements needded to drop its enum
+ * (usually invoked from getModifyEnumSQL()
+ */
+ function getDropEnumSQL($xmldb_table, $xmldb_field) {
+ /// All we have to do is to drop the check constraint
+ return array('ALTER TABLE ' . $this->getTableName($xmldb_table) .
+ ' DROP CONSTRAINT ' . $this->getNameForObject($xmldb_table->getName(), $xmldb_field->getName(), 'ck'));
+ }
+
/**
* Given one XMLDBTable and one XMLDBField, return the SQL statements needded to create its default
* (usually invoked from getModifyDefaultSQL()
return $results;
}
+ /**
+ * Given one XMLDBTable and one XMLDBField, return the SQL statements needded to create its enum
+ * (usually invoked from getModifyEnumSQL()
+ */
+ function getCreateEnumSQL($xmldb_table, $xmldb_field) {
+ /// All we have to do is to create the check constraint
+ return array('ALTER TABLE ' . $this->getTableName($xmldb_table) .
+ ' ADD ' . $this->getEnumExtraSQL($xmldb_table, $xmldb_field));
+ }
+
+ /**
+ * Given one XMLDBTable and one XMLDBField, return the SQL statements needded to drop its enum
+ * (usually invoked from getModifyEnumSQL()
+ */
+ function getDropEnumSQL($xmldb_table, $xmldb_field) {
+ /// All we have to do is to drop the check constraint
+ return array('ALTER TABLE ' . $this->getTableName($xmldb_table) .
+ ' DROP CONSTRAINT ' . $this->getNameForObject($xmldb_table->getName(), $xmldb_field->getName(), 'ck'));
+ }
+
/**
* Given one XMLDBTable and one XMLDBField, return the SQL statements needded to create its default
* (usually invoked from getModifyDefaultSQL()