function drupal_get_schema

Gets the schema definition of a table, or the whole database schema.

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

Parameters

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

bool $rebuild: If TRUE, the schema will be rebuilt instead of retrieved from the cache.

Related topics

25 calls to drupal_get_schema()
AccountFormController::validate in drupal/core/modules/user/lib/Drupal/user/AccountFormController.php
Overrides Drupal\Core\Entity\EntityFormController::submit().
DatabaseTestBase::ensureSampleDataNull in drupal/core/modules/system/lib/Drupal/system/Tests/Database/DatabaseTestBase.php
Sets up tables for NULL handling.
DatabaseTestBase::setUp in drupal/core/modules/system/lib/Drupal/system/Tests/Database/DatabaseTestBase.php
Sets up a Drupal site for running functional and integration tests.
DrupalUnitTestBase::installSchema in drupal/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php
Installs a specific table from a module schema definition.
DrupalUnitTestBaseTest::testEnableModulesInstall in drupal/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php
Tests expected installation behavior of enableModules().

... See full list

File

drupal/core/includes/schema.inc, line 38
Schema API handling functions.

Code

function drupal_get_schema($table = NULL, $rebuild = FALSE) {
  static $schema;
  if ($rebuild || !isset($table)) {
    $schema = drupal_get_complete_schema($rebuild);
  }
  elseif (!isset($schema)) {
    $schema = new SchemaCache();
  }
  if (!isset($table)) {
    return $schema;
  }
  if (isset($schema[$table])) {
    return $schema[$table];
  }
  else {
    return FALSE;
  }
}