Same name and namespace in other branches
  1. 4.6.x includes/database.inc \db_set_active()
  2. 4.7.x includes/database.inc \db_set_active()
  3. 5.x includes/database.inc \db_set_active()
  4. 6.x includes/database.inc \db_set_active()
  5. 8.9.x core/includes/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

The key of the formerly active database.

Related topics

2 calls to db_set_active()
DatabaseLoggingTestCase::testEnableMultiConnectionLogging in modules/simpletest/tests/database_test.test
Test that we can log queries separately on different connections.
DatabaseTasks::connect in includes/install.inc
Check if we can connect to the database.

File

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

Code

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