You are here

function content_database_info in Content Construction Kit (CCK) 5

Same name and namespace in other branches
  1. 6.3 content.module \content_database_info()
  2. 6 content.module \content_database_info()
  3. 6.2 content.module \content_database_info()

Retrieve the database storage location(s) for a field.

Parameters

$field: The field whose database information is requested.

Return value

An array with the keys: "table": The name of the database table where the field data is stored. "columns": An array of columns stored for this field. Each is a collection of information returned from hook_field_settings('database columns'), with the addition of a "column" attribute which holds the name of the database column that stores the data.

20 calls to content_database_info()
content_alter_db_field in ./content_admin.inc
Perform adds, alters, and drops as needed to synchronize the database with new field definitions.
content_field in ./content.module
Implementation of hook_field(). Handles common field housekeeping.
content_update_10 in ./content.install
Fix corrupted db due to a bug in 1.3 release (http://drupal.org/node/115332)
content_update_1004 in ./content.install
Fix corrupted db due to a bug in 1.3 release (http://drupal.org/node/115332)
content_update_1006 in ./content.install
Set text db columns to accept NULL values for mysql (see http://drupal.org/node/108094)

... See full list

File

./content.module, line 910
Allows administrators to associate custom fields to content types.

Code

function content_database_info($field) {
  $field_types = _content_field_types();
  $module = $field_types[$field['type']]['module'];
  $columns = module_invoke($module, 'field_settings', 'database columns', $field);
  $db_info = array();
  if ($field['db_storage'] == CONTENT_DB_STORAGE_PER_FIELD) {
    $db_info['table'] = _content_tablename($field['field_name'], CONTENT_DB_STORAGE_PER_FIELD);
  }
  else {
    $db_info['table'] = _content_tablename($field['type_name'], CONTENT_DB_STORAGE_PER_CONTENT_TYPE);
  }
  if (is_array($columns) && count($columns)) {
    $db_info['columns'] = $columns;
    foreach ($columns as $column_name => $attributes) {
      $db_info['columns'][$column_name]['column'] = $field['field_name'] . '_' . $column_name;
    }
  }
  else {
    $db_info['columns'] = array();
  }
  return $db_info;
}