mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
Changes for Schema Check
This commit is contained in:
parent
cee3d3b64b
commit
32755235e9
@ -164,60 +164,83 @@ function extension_db_status_execute_checks($db_user, $db_password, $db_host, $d
|
|||||||
$db_name = explode(' ', $db_name);
|
$db_name = explode(' ', $db_name);
|
||||||
$db_name = $db_name[0];
|
$db_name = $db_name[0];
|
||||||
|
|
||||||
if ($config['mysqli'] === true) {
|
try {
|
||||||
$connection_test = mysqli_connect($db_host, $db_user, $db_password);
|
if ($config['mysqli']) {
|
||||||
} else {
|
$connection_test = mysqli_connect($db_host, $db_user, $db_password);
|
||||||
$connection_test = mysql_connect($db_host, $db_user, $db_password);
|
} else {
|
||||||
|
$connection_test = mysql_connect($db_host, $db_user, $db_password);
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$connection_test = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$connection_test) {
|
if (!$connection_test) {
|
||||||
ui_print_error_message(
|
ui_print_error_message(__('Unsuccessful connected to the DB'));
|
||||||
__('Unsuccessful connected to the DB')
|
return;
|
||||||
);
|
}
|
||||||
} else {
|
|
||||||
if ($config['mysqli'] === true) {
|
try {
|
||||||
|
$query = "SELECT IF(EXISTS(SELECT 1 FROM information_schema.SCHEMATA WHERE schema_name = '$db_name'), 'true', 'false') AS result";
|
||||||
|
if ($config['mysqli']) {
|
||||||
|
$exist_db = mysqli_fetch_assoc(mysqli_query($connection_test, $query))['result'];
|
||||||
|
} else {
|
||||||
|
$exist_db = mysql_fetch_assoc(mysqli_query($connection_test, $query))['result'];
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
ui_print_error_message(__("There was a problem during verification of the existence of the `$db_name` table"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($exist_db == 'true') {
|
||||||
|
ui_print_error_message(__("The testing DB `$db_name` already exists"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if ($config['mysqli']) {
|
||||||
$create_db = mysqli_query($connection_test, "CREATE DATABASE `$db_name`");
|
$create_db = mysqli_query($connection_test, "CREATE DATABASE `$db_name`");
|
||||||
} else {
|
} else {
|
||||||
$create_db = mysql_query("CREATE DATABASE `$db_name`");
|
$create_db = mysql_query("CREATE DATABASE `$db_name`");
|
||||||
}
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$connection_test = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$create_db) {
|
if (!$create_db) {
|
||||||
ui_print_error_message(
|
ui_print_error_message(__('Unsuccessful created the testing DB'));
|
||||||
__('Unsuccessful created the testing DB')
|
return;
|
||||||
);
|
}
|
||||||
} else {
|
|
||||||
if ($config['mysqli'] === true) {
|
|
||||||
mysqli_select_db($connection_test, $db_name);
|
|
||||||
} else {
|
|
||||||
mysql_select_db($db_name, $connection_test);
|
|
||||||
}
|
|
||||||
|
|
||||||
$install_tables = extension_db_status_execute_sql_file(
|
if ($config['mysqli'] === true) {
|
||||||
$config['homedir'].'/pandoradb.sql',
|
mysqli_select_db($connection_test, $db_name);
|
||||||
$connection_test
|
} else {
|
||||||
);
|
mysql_select_db($db_name, $connection_test);
|
||||||
|
}
|
||||||
|
|
||||||
if (!$install_tables) {
|
$install_tables = extension_db_status_execute_sql_file(
|
||||||
ui_print_error_message(
|
$config['homedir'].'/pandoradb.sql',
|
||||||
__('Unsuccessful installed tables into the testing DB')
|
$connection_test
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
extension_db_check_tables_differences(
|
|
||||||
$connection_test,
|
|
||||||
$connection_system,
|
|
||||||
$db_name,
|
|
||||||
$config['dbname']
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($config['mysqli'] === true) {
|
if (!$install_tables) {
|
||||||
mysqli_select_db($connection_test, $db_name);
|
ui_print_error_message(__('Unsuccessful installed tables into the testing DB'));
|
||||||
mysqli_query($connection_test, "DROP DATABASE IF EXISTS `$db_name`");
|
return;
|
||||||
} else {
|
}
|
||||||
mysql_select_db($db_name, $connection_test);
|
|
||||||
mysql_query("DROP DATABASE IF EXISTS `$db_name`", $connection_test);
|
extension_db_check_tables_differences(
|
||||||
}
|
$connection_test,
|
||||||
}
|
$connection_system,
|
||||||
|
$db_name,
|
||||||
|
$config['dbname']
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
if ($config['mysqli'] === true) {
|
||||||
|
mysqli_select_db($connection_test, $db_name);
|
||||||
|
mysqli_query($connection_test, "DROP DATABASE IF EXISTS `$db_name`");
|
||||||
|
} else {
|
||||||
|
mysql_select_db($db_name, $connection_test);
|
||||||
|
mysql_query("DROP DATABASE IF EXISTS `$db_name`", $connection_test);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user