function Database::getConnectionInfo

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

Gets information on the specified database connection.

Parameters

string $key: (optional) The connection key for which to return information. If not specified, the 'default' connection key will be returned.

Return value

array<string|int,ConnectionInfoArray> An associative array of database information, keyed by target. Defaults to an empty array.

57 calls to Database::getConnectionInfo()
BrowserTestBase::cleanupEnvironment in core/tests/Drupal/Tests/BrowserTestBase.php
Clean up the test environment.
ConnectionTest::testConnectionOptions in core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php
Tests the connection options of the active database.
ConnectionTest::testConnectionRouting in core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php
Tests that connections return appropriate connection objects.
ConnectionTest::testConnectionRoutingOverride in core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php
Tests that connections return appropriate connection objects.
ConnectionTest::testConnectionWithIntegerKeyAndTarget in core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php
Tests deprecation of integer values for connection $key and $target.

... See full list

File

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

Class

Database
Primary front-controller for the database system.

Namespace

Drupal\Core\Database

Code

final public static function getConnectionInfo(string|int $key = 'default') : array {
  if (is_int($key)) {
    @trigger_error('Passing an integer value to the $key parameter in ' . __METHOD__ . '() is deprecated in drupal:11.5.0 and is removed from drupal:13.0.0. Pass only string values instead. See https://www.drupal.org/node/3577925', E_USER_DEPRECATED);
  }
  if (!empty(self::$databaseInfo[$key])) {
    return self::$databaseInfo[$key];
  }
  return [];
}

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