Same name and namespace in other branches
  1. 10 core/includes/install.inc \drupal_get_database_types()
  2. 8.9.x core/includes/install.inc \drupal_get_database_types()
  3. 9 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
API functions for installing modules and themes.

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;
}