From f384b1af87561d98f181f17d8512b2eae75f0872 Mon Sep 17 00:00:00 2001 From: jakubvrana Date: Tue, 30 Sep 2008 09:40:38 +0000 Subject: [PATCH] Error conditions git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@504 7c3ca157-0c34-0410-bff1-cbf682f78f5c --- abstraction.inc.php | 9 +++++++++ dump.inc.php | 2 +- export.inc.php | 2 +- index.php | 5 ++--- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/abstraction.inc.php b/abstraction.inc.php index a02933cc..a0a60b66 100644 --- a/abstraction.inc.php +++ b/abstraction.inc.php @@ -19,6 +19,9 @@ if (extension_loaded("mysqli")) { } function result($result, $field = 0) { + if (!$result) { + return false; + } $row = $result->fetch_array(); return $row[$field]; } @@ -72,6 +75,9 @@ if (extension_loaded("mysqli")) { } function result($result, $field = 0) { + if (!$result) { + return false; + } return mysql_result($result->_result, 0, $field); } @@ -160,6 +166,9 @@ if (extension_loaded("mysqli")) { } function result($result, $field = 0) { + if (!$result) { + return false; + } $row = $result->fetch(); return $row[$field]; } diff --git a/dump.inc.php b/dump.inc.php index bad01177..480d321a 100644 --- a/dump.inc.php +++ b/dump.inc.php @@ -16,7 +16,7 @@ if ($_POST) { echo "SET NAMES utf8;\n"; echo "SET foreign_key_checks = 0;\n"; echo "SET time_zone = '" . $mysql->escape_string($mysql->result($mysql->query("SELECT @@time_zone"))) . "';\n"; - echo "SET max_allowed_packet = $max_packet, GLOBAL max_allowed_packet = $max_packet;\n"; + echo "SET max_allowed_packet = $max_packet;\n"; // ignored because of MySQL bug #22891 echo "\n"; } diff --git a/export.inc.php b/export.inc.php index 48794a30..95f61ba8 100644 --- a/export.inc.php +++ b/export.inc.php @@ -32,7 +32,7 @@ function dump_table($table, $style, $is_view = false) { } if ($row_size > $max_packet) { $max_packet = min(1073741824, 1024 * ceil($row_size / 1024)); - echo "SET max_allowed_packet = $max_packet, GLOBAL max_allowed_packet = $max_packet;\n"; + echo "SET max_allowed_packet = $max_packet;\n"; } } } diff --git a/index.php b/index.php index 87fd6edb..85067acc 100644 --- a/index.php +++ b/index.php @@ -160,7 +160,7 @@ if (isset($_GET["download"])) { echo '' . (isset($row["Rows"]) ? '' . htmlspecialchars($row["Name"]) . "$row[Engine]$row[Collation]" : ' ' . htmlspecialchars($row["Name"]) . '' . lang('View')); $row["count"] = $mysql->result($mysql->query("SELECT COUNT(*) FROM " . idf_escape($row["Name"]))); foreach ((isset($row["Rows"]) ? array("Data_length" => "create", "Index_length" => "indexes", "Data_free" => "edit", "Auto_increment" => "create") : array()) + array("count" => "select") as $key => $link) { - echo '' . (isset($row[$key]) ? '' . number_format($row[$key], 0, '.', lang(',')) . '' : ' '); + echo '' . (strlen($row[$key]) ? '' . number_format($row[$key], 0, '.', lang(',')) . '' : ' '); } echo "\n"; } @@ -190,9 +190,8 @@ if (isset($_GET["download"])) { echo '

' . lang('Create procedure') . ' ' . lang('Create function') . "

\n"; } - if ($mysql->server_info >= 5.1) { + if ($mysql->server_info >= 5.1 && ($result = $mysql->query("SHOW EVENTS"))) { echo "

" . lang('Events') . "

\n"; - $result = $mysql->query("SHOW EVENTS"); if ($result->num_rows) { echo "\n"; echo "\n";
" . lang('Name') . "" . lang('Schedule') . "" . lang('Start') . "" . lang('End') . "