function Database::setActiveConnection

Same name and namespace in other branches
  1. 10 core/lib/Drupal/Core/Database/Database.php \Drupal\Core\Database\Database::setActiveConnection()
  2. 11.x core/lib/Drupal/Core/Database/Database.php \Drupal\Core\Database\Database::setActiveConnection()
  3. 9 core/lib/Drupal/Core/Database/Database.php \Drupal\Core\Database\Database::setActiveConnection()
  4. 8.9.x core/lib/Drupal/Core/Database/Database.php \Drupal\Core\Database\Database::setActiveConnection()

Sets the active connection to the specified key.

Return value

The previous database connection key.

2 calls to Database::setActiveConnection()
db_set_active in includes/database/database.inc
Sets a new active database.
SchemaTestCase::testFindTables in modules/simpletest/tests/schema.test
Tests the findTables() method.

File

includes/database/database.inc, line 1607

Class

Database
Primary front-controller for the database system.

Code

final public static function setActiveConnection($key = 'default') {
  if (empty(self::$databaseInfo)) {
    self::parseConnectionInfo();
  }
  if (!empty(self::$databaseInfo[$key])) {
    $old_key = self::$activeKey;
    self::$activeKey = $key;
    return $old_key;
  }
}

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