drupal_get_schema

Хочешь помочь с переводом? Это очень просто и быстро. Лишь зарегистрируйся, и можешь тут же начать переводить.

includes/common.inc, строка 3161

Версии
6
drupal_get_schema($table = NULL, $rebuild = FALSE)

Возвращает схему определенной таблицы или всей базы данных сайта.

The returned schema will include any modifications made by any module that implements hook_schema_alter().

Параметры

$table The name of the table. If not given, the schema of all tables is returned.

$rebuild If true, the schema will be rebuilt instead of retrieved from the cache.

Связанные темы

▾ 2 функции вызывают drupal_get_schema()

drupal_schema_fields_sql in includes/common.inc
Извлекает список столбцов таблицы. Этот список может использоваться при составлении SQL-запросов.
drupal_write_record in includes/common.inc
Сохраняет запись в базу данных согласно схеме.

Код

<?php
function drupal_get_schema($table = NULL, $rebuild = FALSE) {
  static $schema = array();

  if (empty($schema) || $rebuild) {
    // Try to load the schema from cache.
    if (!$rebuild && $cached = cache_get('schema')) {
      $schema = $cached->data;
    }
    // Otherwise, rebuild the schema cache.
    else {
      $schema = array();
      // Load the .install files to get hook_schema.
      module_load_all_includes('install');

      // Invoke hook_schema for all modules.
      foreach (module_implements('schema') as $module) {
        $current = module_invoke($module, 'schema');
        _drupal_initialize_schema($module, $current);
        $schema = array_merge($schema, $current);
      }

      drupal_alter('schema', $schema);
      cache_set('schema', $schema);
    }
  }

  if (!isset($table)) {
    return $schema;
  }
  elseif (isset($schema[$table])) {
    return $schema[$table];
  }
  else {
    return FALSE;
  }
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии

Вход в систему