You are here

function db_drop_table in Drupal 8

Same name and namespace in other branches
  1. 6 includes/database.mysql-common.inc \db_drop_table()
  2. 6 includes/database.pgsql.inc \db_drop_table()
  3. 7 includes/database/database.inc \db_drop_table()

Drops a table.

Parameters

$table: The table to be dropped.

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 dropTable() on it. For example, $injected_database->schema()->dropTable($table);

See also

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

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

Related topics

1 call to db_drop_table()
DatabaseLegacyTest::testDbDropTable in core/tests/Drupal/KernelTests/Core/Database/DatabaseLegacyTest.php
Tests the db_drop_table() function.

File

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

Code

function db_drop_table($table) {
  @trigger_error('db_drop_table() is deprecated in drupal:8.0.0. It will be removed from drupal:9.0.0. Use \\Drupal\\Core\\Database\\Database::getConnection()->schema()->dropTable() instead. See https://www.drupal.org/node/2993033', E_USER_DEPRECATED);
  return Database::getConnection()
    ->schema()
    ->dropTable($table);
}