From f9df34cb29196aab83cb3c8766528e66f709b174 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Mon, 26 Jan 2015 14:54:49 +0100 Subject: [PATCH] Some changes in the db_status extension. --- pandora_console/extensions/db_status.php | 52 ++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/pandora_console/extensions/db_status.php b/pandora_console/extensions/db_status.php index ccf6b753b5..248a1b3be1 100755 --- a/pandora_console/extensions/db_status.php +++ b/pandora_console/extensions/db_status.php @@ -191,6 +191,23 @@ function extension_db_check_tables_differences($connection_test, __('Unsuccessful the DB Pandora has not all tables. The tables lost are (%s)', implode(", ", $diff_tables))); + if (!empty($diff_tables)) { + foreach ($diff_tables as $table) { + mysql_select_db($db_name_test, $connection_test); + $result = mysql_query("SHOW CREATE TABLE " . $table, $connection_test); + $tables_test = array(); + while ($row = mysql_fetch_array ($result)) { + ui_print_info_message( + __('You can execute this SQL query for to fix.') . "
" . + '
' .
+						$row[1] .
+					'
' + ); + } + mysql_free_result ($result); + } + } + // --------------- Check the fields ------------------------------- $correct_fields = true; @@ -237,6 +254,12 @@ function extension_db_check_tables_differences($connection_test, ui_print_error_message( __('Unsuccessful the table %s has not the field %s', $table, $name_field)); + ui_print_info_message( + __('You can execute this SQL query for to fix.') . "
" . + '
' .
+						"ALTER TABLE " . $table . " ADD COLUMN " . $name_field . " text;" .
+					'
' + ); } else { $correct_fields = false; @@ -251,26 +274,55 @@ function extension_db_check_tables_differences($connection_test, ui_print_error_message( __('Unsuccessful the field %s in the table %s must be setted the type with %s.', $name_field, $table, $value)); + ui_print_info_message( + __('You can execute this SQL query for to fix.') . "
" . + '
' .
+										"ALTER TABLE " . $table . " MODIFY COLUMN " . $field . " " . $value . ";" .
+									'
' + ); break; case 'null': ui_print_error_message( __('Unsuccessful the field %s in the table %s must be setted the null values with %s.', $name_field, $table, $value)); + if ($value == "no") { + ui_print_info_message( + __('You can execute this SQL query for to fix.') . "
" . + '
' .
+											"ALTER TABLE " . $table . " MODIFY COLUMN " . $field . "INT NULL;" .
+										'
' + ); + } + else { + ui_print_info_message( + __('You can execute this SQL query for to fix.') . "
" . + '
' .
+											"ALTER TABLE " . $table . " MODIFY COLUMN " . $field . "INT NOT NULL;" .
+										'
' + ); + } + break; case 'key': ui_print_error_message( __('Unsuccessful the field %s in the table %s must be setted the key as defined in the SQL file.', $name_field, $table)); + ui_print_info_message( + __('Please check the SQL file for to know the kind of key needed.')); break; case 'default': ui_print_error_message( __('Unsuccessful the field %s in the table %s must be setted the default value as %s.', $name_field, $table, $value)); + ui_print_info_message( + __('Please check the SQL file for to know the kind of default value needed.')); break; case 'extra': ui_print_error_message( __('Unsuccessful the field %s in the table %s must be setted as defined in the SQL file.', $name_field, $table)); + ui_print_info_message( + __('Please check the SQL file for to know the kind of extra config needed.')); break; } }