You are here

function _content_tablename in Content Construction Kit (CCK) 5

Same name and namespace in other branches
  1. 6.3 content.module \_content_tablename()
  2. 6 content.module \_content_tablename()
  3. 6.2 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

$entity: 'field' or 'type'

Return value

A string containing the generated name for the database table

9 calls to _content_tablename()
content_database_info in ./content.module
Retrieve the database storage location(s) for a field.
content_delete in ./content.module
Delete node type fields.
content_delete_revision in ./content.module
delete node type fields for a revision.
content_type_create in ./content_crud.inc
Make changes needed when a content type is created.
content_type_delete in ./content_crud.inc
Make changes needed when a content type is deleted.

... See full list

File

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

Code

function _content_tablename($name, $entity, $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}-{$entity}") {
    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}";
  }
}