function db_field_set_default in Drupal 6
Same name in this branch
- 6 includes/database.mysql-common.inc \db_field_set_default()
- 6 includes/database.pgsql.inc \db_field_set_default()
Same name and namespace in other branches
- 8 core/includes/database.inc \db_field_set_default()
- 7 includes/database/database.inc \db_field_set_default()
Set the default value for a field.
Parameters
$ret: Array to which query results will be added.
$table: The table to be altered.
$field: The field to be altered.
$default: Default value to be set. NULL for 'default NULL'.
Related topics
File
- includes/
database.mysql-common.inc, line 346 - Functions shared between mysql and mysqli database engines.
Code
function db_field_set_default(&$ret, $table, $field, $default) {
if ($default === NULL) {
$default = 'NULL';
}
else {
$default = is_string($default) ? "'{$default}'" : $default;
}
$ret[] = update_sql('ALTER TABLE {' . $table . '} ALTER COLUMN ' . $field . ' SET DEFAULT ' . $default);
}