Same name and namespace in other branches
  1. 6.x includes/database.inc \db_create_table()
  2. 7.x includes/database/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

in drupal:8.0.0 and is removed from 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. For example, $injected_database->schema()->createTable($name, $table);

See also

https://www.drupal.org/node/2993033

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

Related topics

1 call to db_create_table()
DatabaseLegacyTest::testDbCreateTable in core/tests/Drupal/KernelTests/Core/Database/DatabaseLegacyTest.php
Tests deprecation of the db_create_table() function.

File

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

Code

function db_create_table($name, $table) {
  @trigger_error('db_create_table() is deprecated in drupal:8.0.0. It will be removed from 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. For example, $injected_database->schema()->createTable($name, $table). See https://www.drupal.org/node/2993033', E_USER_DEPRECATED);
  return Database::getConnection()
    ->schema()
    ->createTable($name, $table);
}