function db_set_active

Same name in other branches
  1. 7.x 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

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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.