function db_set_active

Sets a new active database.

Parameters

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

Return value

The key of the formerly active database.

Related topics

5 calls to db_set_active()
LoggingTest::testEnableMultiConnectionLogging in drupal/core/modules/system/lib/Drupal/system/Tests/Database/LoggingTest.php
Tests that we can log queries separately on different connections.
Tasks::connect in drupal/core/lib/Drupal/Core/Database/Install/Tasks.php
Check if we can connect to the database.
Tasks::connect in drupal/core/lib/Drupal/Core/Database/Driver/mysql/Install/Tasks.php
Check database connection and attempt to create database if the database is missing.
Tasks::connect in drupal/core/lib/Drupal/Core/Database/Driver/sqlite/Install/Tasks.php
Check database connection and attempt to create database if the database is missing.
Tasks::connect in drupal/core/lib/Drupal/Core/Database/Driver/pgsql/Install/Tasks.php
Check database connection and attempt to create database if the database is missing.

File

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

Code

function db_set_active($key = 'default') {
  return Database::setActiveConnection($key);
}