You are here

function _content_tablename in Content Construction Kit (CCK) 6.2

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

Generate a table name for a field or a content type.

Parameters

$name: The name of the content type or content field

$storage: CONTENT_DB_STORAGE_PER_FIELD or CONTENT_DB_STORAGE_PER_CONTENT_TYPE

Return value

A string containing the generated name for the database table

9 calls to _content_tablename()
content_alter_db in includes/content.admin.inc
Perform adds, alters, and drops as needed to synchronize the database with new field definitions.
content_database_info in ./content.module
Retrieve the database storage location(s) for a field.
content_field_instance_delete in includes/content.crud.inc
Delete an existing field instance.
content_schema in ./content.install
Implementation of hook_schema.
content_type_delete in includes/content.crud.inc
Make changes needed when a content type is deleted.

... See full list

File

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

Code

function _content_tablename($name, $storage, $version = NULL) {
  if (is_null($version)) {
    $version = variable_get('content_schema_version', 0);
  }
  if ($version < 1003) {
    $version = 0;
  }
  else {
    $version = 1003;
  }
  $name = str_replace('-', '_', $name);
  switch ("{$version}-{$storage}") {
    case '0-' . CONTENT_DB_STORAGE_PER_CONTENT_TYPE:
      return "node_{$name}";
    case '0-' . CONTENT_DB_STORAGE_PER_FIELD:
      return "node_data_{$name}";
    case '1003-' . CONTENT_DB_STORAGE_PER_CONTENT_TYPE:
      return "content_type_{$name}";
    case '1003-' . CONTENT_DB_STORAGE_PER_FIELD:
      return "content_{$name}";
  }
}