You are here

function db_field_set_default in Drupal 6

Same name in this branch
  1. 6 includes/database.mysql-common.inc \db_field_set_default()
  2. 6 includes/database.pgsql.inc \db_field_set_default()
Same name and namespace in other branches
  1. 8 core/includes/database.inc \db_field_set_default()
  2. 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.pgsql.inc, line 716
Database interface code for PostgreSQL database servers.

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);
}