diff --git a/install.php b/install.php index e828fa814b..092172d35f 100644 --- a/install.php +++ b/install.php @@ -181,6 +181,18 @@ $external_libraries=array( 'check_class'=>'Validate' ) ); +$dbModules = array( + 'mysql' => array( + 'name' => 'MySQL', + 'check_module' => 'mysql', // mysqli? + 'installer' => 'mysql_db_installer', + ), + 'pgsql' => array( + 'name' => 'PostgreSQL', + 'check_module' => 'pgsql', + 'installer' => 'pgsql_db_installer', + ), +); function main() { @@ -238,8 +250,18 @@ function checkPrereqs() $pass = false; } } - if (!checkExtension('pgsql') && !checkExtension('mysql')) { - ?>

Cannot find mysql or pgsql extension. You need one or the other:

$info) { + if (!checkExtension($info['check_module'])) { + $missingExtensions[] = $info['check_module']; + } + } + if (count($missingExtensions) == count($dbModules)) { + $req = implode(', ', $missingExtensions); + ?>

Cannot find database support. You need at least one of these PHP extensions installed:

$info) { + if (checkExtension($info['check_module'])) { + $dbRadios .= " $info[name]
\n"; + $checked = ''; + } + } echo<< @@ -376,8 +407,7 @@ function showForm()
  • - MySQL
    - PostgreSQL
    + $dbRadios

    Database type

  • @@ -465,17 +495,9 @@ function handlePost() return; } - // FIXME: use PEAR::DB or PDO instead of our own switch - - switch($dbtype) { - case 'mysql': - $db = mysql_db_installer($host, $database, $username, $password); - break; - case 'pgsql': - $db = pgsql_db_installer($host, $database, $username, $password); - break; - default: - } + global $dbModules; + $db = call_user_func($dbModules[$dbtype]['installer'], + $host, $database, $username, $password); if (!$db) { // database connection failed, do not move on to create config file.