function db_set_active

7.x db_set_active($key = 'default')
5.x db_set_active($name = 'default')
6.x db_set_active($name = 'default')
8.x db_set_active($key = 'default')

Sets a new active database.


$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 drupal/modules/simpletest/tests/database_test.test
Test that we can log queries separately on different connections.
DatabaseTasks::connect in drupal/includes/
Check if we can connect to the database.


drupal/includes/database/, line 2587
Core systems for the database layer.


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