You are here

function db_set_active in Drupal 8

Same name and namespace in other branches
  1. 4 includes/database.inc \db_set_active()
  2. 5 includes/database.inc \db_set_active()
  3. 6 includes/database.inc \db_set_active()
  4. 7 includes/database/database.inc \db_set_active()

Sets a new active database.

Parameters

$key: The key in the $databases array to set as the default database.

Return value

string|null The key of the formerly active database.

Deprecated

in drupal:8.0.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Database\Database::setActiveConnection().

See also

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

Related topics

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

File

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

Code

function db_set_active($key = 'default') {
  @trigger_error('db_set_active() is deprecated in drupal:8.0.0. It will be removed from drupal:9.0.0. Use \\Drupal\\Core\\Database\\Database::setActiveConnection() instead. See https://www.drupal.org/node/2993033', E_USER_DEPRECATED);
  return Database::setActiveConnection($key);
}