Installer now checks that MySQL extension is present - see bug 1982

This commit is contained in:
moodler 2004-09-23 05:40:53 +00:00
parent 8c3dba735b
commit fe51520688
2 changed files with 28 additions and 17 deletions

View file

@ -213,24 +213,34 @@ if ($INSTALL['stage'] == 3) {
} }
} }
$db = &ADONewConnection($INSTALL['dbtype']); if ($INSTALL['dbtype'] == 'mysql') { /// Check MySQL extension is present
if (!extension_loaded('mysql')) {
$errormsg = get_string('mysqlextensionisnotpresentinphp', 'install');
$nextstage = 3;
}
}
error_reporting(0); // Hide errors if (empty($errormsg)) {
if (! $dbconnected = $db->Connect($INSTALL['dbhost'],$INSTALL['dbuser'],$INSTALL['dbpass'],$INSTALL['dbname'])) { $db = &ADONewConnection($INSTALL['dbtype']);
/// The following doesn't seem to work but we're working on it
/// If you come up with a solution for creating a database in MySQL error_reporting(0); // Hide errors
/// feel free to put it in and let us know
if ($dbconnected = $db->Connect($INSTALL['dbhost'],$INSTALL['dbuser'],$INSTALL['dbpass'])) { if (! $dbconnected = $db->Connect($INSTALL['dbhost'],$INSTALL['dbuser'],$INSTALL['dbpass'],$INSTALL['dbname'])) {
switch ($INSTALL['dbtype']) { /// Try to create a database /// The following doesn't seem to work but we're working on it
case 'mysql': /// If you come up with a solution for creating a database in MySQL
if ($db->Execute("CREATE DATABASE {$INSTALL['dbname']};")) { /// feel free to put it in and let us know
$dbconnected = $db->Connect($INSTALL['dbhost'],$INSTALL['dbuser'],$INSTALL['dbpass'],$INSTALL['dbname']); if ($dbconnected = $db->Connect($INSTALL['dbhost'],$INSTALL['dbuser'],$INSTALL['dbpass'])) {
} else { switch ($INSTALL['dbtype']) { /// Try to create a database
$errormsg = get_string('dbcreationerror', 'install'); case 'mysql':
$nextstage = 3; if ($db->Execute("CREATE DATABASE {$INSTALL['dbname']};")) {
} $dbconnected = $db->Connect($INSTALL['dbhost'],$INSTALL['dbuser'],$INSTALL['dbpass'],$INSTALL['dbname']);
break; } else {
$errormsg = get_string('dbcreationerror', 'install');
$nextstage = 3;
}
break;
}
} }
} }
} }

View file

@ -110,6 +110,7 @@ $string['memorylimithelp'] = "
<p>However, on some servers this will prevent <b>all</b> PHP pages from working <p>However, on some servers this will prevent <b>all</b> PHP pages from working
(you will see errors when you look at pages) so you'll have to remove the .htaccess file. (you will see errors when you look at pages) so you'll have to remove the .htaccess file.
</ol>"; </ol>";
$string['mysqlextensionisnotpresentinphp'] = 'PHP has not been properly configured with the MySQL extension so that it can communicate with MySQL. Please check your php.ini file or recompile PHP.';
$string['pass'] = 'Pass'; $string['pass'] = 'Pass';
$string['phpversion'] = 'PHP version'; $string['phpversion'] = 'PHP version';
$string['phpversionerror'] = 'PHP version must be at least 4.1.0'; $string['phpversionerror'] = 'PHP version must be at least 4.1.0';