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

19 calls to drupal_get_schema()
AccountFormController::validate in drupal/core/modules/user/lib/Drupal/user/AccountFormController.php
Overrides Drupal\Core\Entity\EntityFormController::submit().
DatabaseStorageControllerNG::mapToDataStorageRecord in drupal/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php
Maps from an entity object to the storage record of the data table.
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().
DrupalUnitTestBaseTest::testInstallSchema in drupal/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php
Tests expected behavior of installSchema().

... 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;
  }
}