You are here

function content_database_info in Content Construction Kit (CCK) 6

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

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

TODO : add a word about why it's not included in the global _content_type_info array.

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.

16 calls to content_database_info()
content_alter_db in includes/content.admin.inc
Perform adds, alters, and drops as needed to synchronize the database with new field definitions.
content_field_batch_update in includes/content.admin.inc
Content Field Batch Update Operation
content_storage in ./content.module
TODO : PHPdoc
content_views_field_views_data in includes/content.views.inc
nodereference_field_settings in modules/nodereference/nodereference.module
Implementation of hook_field_settings().

... See full list

File

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

Code

function content_database_info($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);
  }
  $db_info['columns'] = (array) $field['columns'];

  // Generate column names for this field from generic column names.
  foreach ($db_info['columns'] as $column_name => $attributes) {
    $db_info['columns'][$column_name]['column'] = $field['field_name'] . '_' . $column_name;
  }
  return $db_info;
}