ENH: Some webhosters require username/password credentials to test for

existing DB server
This commit is contained in:
dompie 2012-01-11 16:05:19 +01:00
parent ccbcb386e7
commit 3c09e9dfc4

View File

@ -1,10 +1,10 @@
<?php <?php
/** /**
* This is a helper class for the SS installer. * This is a helper class for the SS installer.
* *
* It does all the specific checking for MySQLDatabase * It does all the specific checking for MySQLDatabase
* to ensure that the configuration is setup correctly. * to ensure that the configuration is setup correctly.
* *
* @package sappire * @package sappire
* @subpackage model * @subpackage model
*/ */
@ -13,7 +13,7 @@ class MySQLDatabaseConfigurationHelper implements DatabaseConfigurationHelper {
/** /**
* Ensure that the database function for connectivity is available. * Ensure that the database function for connectivity is available.
* If it is, we assume the PHP module for this database has been setup correctly. * If it is, we assume the PHP module for this database has been setup correctly.
* *
* @param array $databaseConfig Associative array of db configuration, e.g. "server", "username" etc * @param array $databaseConfig Associative array of db configuration, e.g. "server", "username" etc
* @return boolean * @return boolean
*/ */
@ -29,7 +29,7 @@ class MySQLDatabaseConfigurationHelper implements DatabaseConfigurationHelper {
public function requireDatabaseServer($databaseConfig) { public function requireDatabaseServer($databaseConfig) {
$success = false; $success = false;
$error = ''; $error = '';
$conn = @mysql_connect($databaseConfig['server'], null, null); $conn = @mysql_connect($databaseConfig['server'], $databaseConfig['username'], $databaseConfig['password']);
if($conn || mysql_errno() < 2000) { if($conn || mysql_errno() < 2000) {
$success = true; $success = true;
} else { } else {
@ -109,7 +109,7 @@ class MySQLDatabaseConfigurationHelper implements DatabaseConfigurationHelper {
/** /**
* Ensure that the database connection is able to use an existing database, * Ensure that the database connection is able to use an existing database,
* or be able to create one if it doesn't exist. * or be able to create one if it doesn't exist.
* *
* @param array $databaseConfig Associative array of db configuration, e.g. "server", "username" etc * @param array $databaseConfig Associative array of db configuration, e.g. "server", "username" etc
* @return array Result - e.g. array('success' => true, 'alreadyExists' => 'true') * @return array Result - e.g. array('success' => true, 'alreadyExists' => 'true')
*/ */