function db_rename_table
Same name in other branches
- 7.x includes/database/database.inc \db_rename_table()
Renames a table.
Parameters
$table: The current name of the table to be renamed.
$new_name: The new name for the table.
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 renameTable() on it. For example, $injected_database->schema()->renameTable($table, $new_name);
See also
https://www.drupal.org/node/2993033
\Drupal\Core\Database\Schema::renameTable()
Related topics
1 call to db_rename_table()
- DatabaseLegacyTest::testDbRenameTable in core/
tests/ Drupal/ KernelTests/ Core/ Database/ DatabaseLegacyTest.php - Tests deprecation of the db_rename_table() function.
File
-
core/
includes/ database.inc, line 772
Code
function db_rename_table($table, $new_name) {
@trigger_error('db_rename_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 renameTable() on it. For example, $injected_database->schema()->renameTable($table, $new_name). See https://www.drupal.org/node/2993033', E_USER_DEPRECATED);
return Database::getConnection()->schema()
->renameTable($table, $new_name);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.