function drupal_get_database_types
Same name in other branches
- 9 core/includes/install.inc \drupal_get_database_types()
- 8.9.x core/includes/install.inc \drupal_get_database_types()
- 10 core/includes/install.inc \drupal_get_database_types()
Returns all supported database installer objects that are compiled into PHP.
Return value
An array of database installer objects compiled into PHP.
3 calls to drupal_get_database_types()
- drupal_detect_database_types in includes/
install.inc - Detects all supported databases that are compiled into PHP.
- install_database_errors in includes/
install.core.inc - Checks a database connection and returns any errors.
- install_settings_form in includes/
install.core.inc - Form constructor for a form to configure and rewrite settings.php.
File
-
includes/
install.inc, line 253
Code
function drupal_get_database_types() {
$databases = array();
// We define a driver as a directory in /includes/database that in turn
// contains a database.inc file. That allows us to drop in additional drivers
// without modifying the installer.
// Because we have no registry yet, we need to also include the install.inc
// file for the driver explicitly.
require_once DRUPAL_ROOT . '/includes/database/database.inc';
foreach (file_scan_directory(DRUPAL_ROOT . '/includes/database', '/^[a-z]*$/i', array(
'recurse' => FALSE,
)) as $file) {
if (file_exists($file->uri . '/database.inc') && file_exists($file->uri . '/install.inc')) {
$drivers[$file->filename] = $file->uri;
}
}
foreach ($drivers as $driver => $file) {
$installer = db_installer_object($driver);
if ($installer->installable()) {
$databases[$driver] = $installer;
}
}
// Usability: unconditionally put the MySQL driver on top.
if (isset($databases['mysql'])) {
$mysql_database = $databases['mysql'];
unset($databases['mysql']);
$databases = array(
'mysql' => $mysql_database,
) + $databases;
}
return $databases;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.