function Database::removeConnection

Same name in other branches
  1. 7.x includes/database/database.inc \Database::removeConnection()
  2. 9 core/lib/Drupal/Core/Database/Database.php \Drupal\Core\Database\Database::removeConnection()
  3. 8.9.x core/lib/Drupal/Core/Database/Database.php \Drupal\Core\Database\Database::removeConnection()
  4. 11.x core/lib/Drupal/Core/Database/Database.php \Drupal\Core\Database\Database::removeConnection()

Remove a connection and its corresponding connection information.

Parameters

string $key: The connection key.

Return value

bool TRUE in case of success, FALSE otherwise.

19 calls to Database::removeConnection()
ConnectionTest::tearDown in core/tests/Drupal/Tests/Core/Database/ConnectionTest.php
DatabaseStorageTest::testConcurrent in core/tests/Drupal/KernelTests/Core/KeyValueStore/DatabaseStorageTest.php
Tests asynchronous table creation.
DbCommandBase::getDatabaseConnection in core/lib/Drupal/Core/Command/DbCommandBase.php
Parse input options decide on a database.
DbCommandBaseTest::testSpecifyDbUrl in core/modules/system/tests/src/Kernel/Scripts/DbCommandBaseTest.php
Tests supplying database connection as a URL.
DirectoryTest::testMultiplePrepareDirectory in core/tests/Drupal/KernelTests/Core/File/DirectoryTest.php
Tests asynchronous directory creation.

... See full list

File

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

Class

Database
Primary front-controller for the database system.

Namespace

Drupal\Core\Database

Code

public static final function removeConnection($key) {
    if (isset(self::$databaseInfo[$key])) {
        self::closeConnection(NULL, $key);
        unset(self::$databaseInfo[$key]);
        return TRUE;
    }
    else {
        return FALSE;
    }
}

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