1 database.inc final public static Database::setActiveConnection($key = 'default')

Sets the active connection to the specified key.

Parameters

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

Return value

string|null: The previous database connection key if the connection changed. NULL if the connection was not changed.

File

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

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;
  }
  return NULL;
}