drupal_detect_database_types
- Versions
- 5 – 7
drupal_detect_database_types()
Detect all supported databases that are compiled into PHP.
Return value
An array of database types compiled into PHP.
Code
includes/install.inc, line 207
<?php
function drupal_detect_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) {
include_once "{$file->uri}/install.inc";
include_once "{$file->uri}/database.inc";
$drivers[$file->filename] = $file->uri;
}
foreach ($drivers as $driver => $file) {
$class = 'DatabaseTasks_' . $driver;
$installer = new $class();
if ($installer->installable()) {
$databases[$driver] = $installer->name();
}
}
// 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;
}
?>Login or register to post comments 