You are here

function db_create_table in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/includes/database.inc \db_create_table()

Creates a new table from a Drupal table definition.

Parameters

string $name: The name of the table to create.

array $table: A Schema API table definition array.

Deprecated

as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get a database connection injected into your service from the container, get its schema driver, and call createTable() on it. E.g. $injected_database->schema()->createTable($name, $table);

See also

\Drupal\Core\Database\Schema::createTable()

Related topics

8 calls to db_create_table()
drupal_install_schema in core/includes/schema.inc
Creates all tables defined in a module's hook_schema().
SchemaTest::assertFieldAdditionRemoval in core/modules/system/src/Tests/Database/SchemaTest.php
Asserts that a given field can be added and removed from a table.
SchemaTest::assertFieldChange in core/modules/system/src/Tests/Database/SchemaTest.php
Asserts that a field can be changed from one spec to another.
SchemaTest::testIndexLength in core/modules/system/src/Tests/Database/SchemaTest.php
Tests that indexes on string fields are limited to 191 characters on MySQL.
SchemaTest::testSchema in core/modules/system/src/Tests/Database/SchemaTest.php
Tests database interactions.

... See full list

File

core/includes/database.inc, line 573
Core systems for the database layer.

Code

function db_create_table($name, $table) {
  return Database::getConnection()
    ->schema()
    ->createTable($name, $table);
}