W3cubDocs

/Drupal 8

final public static function Database::setActiveConnection

final public static Database::setActiveConnection($key = 'default')

Sets the active connection to the specified key.

Return value

string|null The previous database connection key.

File

core/lib/Drupal/Core/Database/Database.php, line 191

Class

Database
Primary front-controller for the database system.

Namespace

Drupal\Core\Database

Code

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

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Database!Database.php/function/Database::setActiveConnection/8.1.x