/** * Give one xmldb_field, returns the correct "default value" for the current configuration * * @param xmldb_field $xmldb_field The field. * @return The default value of the field. */ public function getDefaultValue($xmldb_field) { $default = null; if ($xmldb_field->getDefault() !== NULL) { if ($xmldb_field->getType() == XMLDB_TYPE_CHAR || $xmldb_field->getType() == XMLDB_TYPE_TEXT) { if ($xmldb_field->getDefault() === '') { // If passing empty default, use the $default_for_char one instead $default = "'" . $this->default_for_char . "'"; } else { $default = "'" . $this->addslashes($xmldb_field->getDefault()) . "'"; } } else { $default = $xmldb_field->getDefault(); } } else { /// We force default '' for not null char columns without proper default /// some day this should be out! if ($this->default_for_char !== NULL && $xmldb_field->getType() == XMLDB_TYPE_CHAR && $xmldb_field->getNotNull()) { $default = "'" . $this->default_for_char . "'"; } else { /// If the DB requires to explicity define some clause to drop one default, do it here /// never applying defaults to TEXT and BINARY fields if ($this->drop_default_value_required && $xmldb_field->getType() != XMLDB_TYPE_TEXT && $xmldb_field->getType() != XMLDB_TYPE_BINARY && !$xmldb_field->getNotNull()) { $default = $this->drop_default_value; } } } return $default; }