function db_field_set_default

7.x database.inc db_field_set_default($table, $field, $default)
6.x database.pgsql.inc db_field_set_default(&$ret, $table, $field, $default)
6.x database.mysql-common.inc db_field_set_default(&$ret, $table, $field, $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

drupal-6.x/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);
}