Same tests to establish connection to the database server when using multiple or single DB

skala
Julio Montoya 15 years ago
parent 5c69a1199b
commit a34d406c88
  1. 15
      main/install/install.lib.php

@ -598,20 +598,14 @@ function database_server_connect() {
} }
/** /**
* In step 3. Tests establishing connection to the database server. Tests also the possibility for multiple databases configuration. * In step 3. Tests establishing connection to the database server.
* Tests also the possibility for multiple databases configuration.
* @return int 1 when there is no problem; * @return int 1 when there is no problem;
* 0 when a new database is impossible to be created, then the multiple databases configuration is impossible too; * 0 when a new database is impossible to be created, then the single/multiple database configuration is impossible too
* -1 when there is no connection established. * -1 when there is no connection established.
*/ */
function test_db_connect($dbHostForm, $dbUsernameForm, $dbPassForm, $singleDbForm, $dbPrefixForm) { function test_db_connect($dbHostForm, $dbUsernameForm, $dbPassForm, $singleDbForm, $dbPrefixForm) {
$dbConnect = -1; $dbConnect = -1;
if ($singleDbForm == 1) {
if (@Database::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm)) !== false) {
$dbConnect = 1;
} else {
$dbConnect = -1;
}
} elseif ($singleDbForm == 0) {
if (@Database::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm)) !== false) { if (@Database::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm)) !== false) {
@Database::query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5) @Database::query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
$multipleDbCheck = @Database::query("CREATE DATABASE ".$dbPrefixForm."test_chamilo_connection"); $multipleDbCheck = @Database::query("CREATE DATABASE ".$dbPrefixForm."test_chamilo_connection");
@ -628,8 +622,7 @@ function test_db_connect($dbHostForm, $dbUsernameForm, $dbPassForm, $singleDbFor
} else { } else {
$dbConnect = -1; $dbConnect = -1;
} }
} return $dbConnect; //return "1"if no problems, "0" if, in case we can't create a new DB and "-1" if there is no connection.
return $dbConnect; //return "1"if no problems, "0" if, in case of multiDB we can't create a new DB and "-1" if there is no connection.
} }
/** /**

Loading…
Cancel
Save