final public static function Database::parseConnectionInfo in Drupal 7
Process the configuration file for database information.
5 calls to Database::parseConnectionInfo()
- Database::getConnectionInfo in includes/
database/ database.inc - Gets information on the specified database connection.
- Database::openConnection in includes/
database/ database.inc - Opens a connection to the server specified by the given key and target.
- Database::renameConnection in includes/
database/ database.inc - Rename a connection and its corresponding connection information.
- Database::setActiveConnection in includes/
database/ database.inc - Sets the active connection to the specified key.
- install_database_errors in includes/
install.core.inc - Checks a database connection and returns any errors.
File
- includes/
database/ database.inc, line 1622 - Core systems for the database layer.
Class
- Database
- Primary front-controller for the database system.
Code
public static final function parseConnectionInfo() {
global $databases;
$database_info = is_array($databases) ? $databases : array();
foreach ($database_info as $index => $info) {
foreach ($database_info[$index] as $target => $value) {
// If there is no "driver" property, then we assume it's an array of
// possible connections for this target. Pick one at random. That allows
// us to have, for example, multiple slave servers.
if (empty($value['driver'])) {
$database_info[$index][$target] = $database_info[$index][$target][mt_rand(0, count($database_info[$index][$target]) - 1)];
}
// Parse the prefix information.
if (!isset($database_info[$index][$target]['prefix'])) {
// Default to an empty prefix.
$database_info[$index][$target]['prefix'] = array(
'default' => '',
);
}
elseif (!is_array($database_info[$index][$target]['prefix'])) {
// Transform the flat form into an array form.
$database_info[$index][$target]['prefix'] = array(
'default' => $database_info[$index][$target]['prefix'],
);
}
}
}
if (!is_array(self::$databaseInfo)) {
self::$databaseInfo = $database_info;
}
else {
foreach ($database_info as $database_key => $database_values) {
foreach ($database_values as $target => $target_values) {
self::$databaseInfo[$database_key][$target] = $target_values;
}
}
}
}