public static function Database::closeConnection in Drupal 9
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Database/Database.php \Drupal\Core\Database\Database::closeConnection()
Closes a connection to the server specified by the given key and target.
Parameters
string $target: The database target name. Defaults to NULL meaning that all target connections will be closed.
string $key: The database connection key. Defaults to NULL which means the active key.
16 calls to Database::closeConnection()
- ConnectionFailureTest::testConnectionFailureLogging in core/
modules/ dblog/ tests/ src/ Kernel/ ConnectionFailureTest.php - Tests logging of connection failures.
- ConnectionTest::testConnectionClosing in core/
tests/ Drupal/ KernelTests/ Core/ Database/ ConnectionTest.php - Tests the closing of a database connection.
- ConnectionUnitTest::testOpenClose in core/
tests/ Drupal/ KernelTests/ Core/ Database/ ConnectionUnitTest.php - Tests Database::closeConnection() without query.
- ConnectionUnitTest::testOpenQueryClose in core/
tests/ Drupal/ KernelTests/ Core/ Database/ ConnectionUnitTest.php - Tests Database::closeConnection() with a query.
- ConnectionUnitTest::testOpenQueryPrefetchClose in core/
tests/ Drupal/ KernelTests/ Core/ Database/ ConnectionUnitTest.php - Tests Database::closeConnection() with a query and custom prefetch method.
File
- core/
lib/ Drupal/ Core/ Database/ Database.php, line 410
Class
- Database
- Primary front-controller for the database system.
Namespace
Drupal\Core\DatabaseCode
public static function closeConnection($target = NULL, $key = NULL) {
// Gets the active connection by default.
if (!isset($key)) {
$key = self::$activeKey;
}
if (isset($target)) {
unset(self::$connections[$key][$target]);
}
else {
unset(self::$connections[$key]);
}
// Force garbage collection to run. This ensures that PDO connection objects
// and destroyed and results in the connections being closed.
gc_collect_cycles();
}