Skip navigation
Help

_drupal_schema_initialize

7 common.inc _drupal_schema_initialize(&$schema, $module, $remove_descriptions = TRUE)

Fill in required default values for table definitions returned by hook_schema().

Parameters

$schema: The schema definition array as it was returned by the module's hook_schema().

$module: The module for which hook_schema() was invoked.

$remove_descriptions: (optional) Whether to additionally remove 'description' keys of all tables and fields to improve performance of serialize() and unserialize(). Defaults to TRUE.

Related topics

3 calls to _drupal_schema_initialize()

File

drupal/includes/common.inc, line 6697
Common functions that many Drupal modules will need to reference.

Code

function _drupal_schema_initialize(&$schema, $module, $remove_descriptions = TRUE) {
  // Set the name and module key for all tables.
  foreach ($schema as $name => &$table) {
    if (empty($table['module'])) {
      $table['module'] = $module;
    }
    if (!isset($table['name'])) {
      $table['name'] = $name;
    }
    if ($remove_descriptions) {
      unset($table['description']);
      foreach ($table['fields'] as &$field) {
        unset($field['description']);
      }
    }
  }
}