public static Database::closeConnection($target = NULL, $key = NULL)
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.
File
- core/lib/Drupal/Core/Database/Database.php, line 399
Class
- Database
- Primary front-controller for the database system.
Namespace
Drupal\Core\Database
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | public static function closeConnection( $target = NULL, $key = NULL) { // Gets the active connection by default. if (!isset( $key )) { $key = self:: $activeKey ; } // To close a connection, it needs to be set to NULL and removed from the // static variable. In all cases, closeConnection() might be called for a // connection that was not opened yet, in which case the key is not defined // yet and we just ensure that the connection key is undefined. if (isset( $target )) { if (isset(self:: $connections [ $key ][ $target ])) { self:: $connections [ $key ][ $target ]->destroy(); self:: $connections [ $key ][ $target ] = NULL; } unset(self:: $connections [ $key ][ $target ]); } else { if (isset(self:: $connections [ $key ])) { foreach (self:: $connections [ $key ] as $target => $connection ) { self:: $connections [ $key ][ $target ]->destroy(); self:: $connections [ $key ][ $target ] = NULL; } } unset(self:: $connections [ $key ]); } } |
Please login to continue.