From c8f50f9ad4b8b9dab95cee067c3d5ea9e094082d Mon Sep 17 00:00:00 2001 From: jakubvrana Date: Wed, 11 Jul 2007 08:24:03 +0000 Subject: [PATCH] $mysql->result takes always first row git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@116 7c3ca157-0c34-0410-bff1-cbf682f78f5c --- abstraction.inc.php | 7 +++---- call.inc.php | 2 +- database.inc.php | 2 +- download.inc.php | 2 +- dump.inc.php | 6 +++--- functions.inc.php | 2 +- select.inc.php | 2 +- view.inc.php | 2 +- 8 files changed, 12 insertions(+), 13 deletions(-) diff --git a/abstraction.inc.php b/abstraction.inc.php index 517c6528..0ecd25ee 100644 --- a/abstraction.inc.php +++ b/abstraction.inc.php @@ -13,8 +13,7 @@ if (extension_loaded("mysqli")) { ); } - function result($result, $offset, $field = 0) { - $result->data_seek($offset); + function result($result, $field = 0) { $row = $result->fetch_array(); return $row[$field]; } @@ -63,8 +62,8 @@ if (extension_loaded("mysqli")) { return false; } - function result($result, $offset, $field = 0) { - return mysql_result($result->_result, $offset, $field); + function result($result, $field = 0) { + return mysql_result($result->_result, 0, $field); } function select_db($database) { diff --git a/call.inc.php b/call.inc.php index 34863c6d..6c620dfc 100644 --- a/call.inc.php +++ b/call.inc.php @@ -6,7 +6,7 @@ function normalize_enum($match) { } $pattern = "\\s*(IN|OUT|INOUT)?\\s*(?:`((?:[^`]+|``)*)`\\s*|\\b(\\S+)\\s+)([a-z]+)(?:\\s*\\(((?:[^'\")]*|$enum_length)+)\\))?\\s*(?:zerofill\\s+)?(unsigned)?"; -$create = $mysql->result($mysql->query("SHOW CREATE " . (isset($_GET["callf"]) ? "FUNCTION" : "PROCEDURE") . " " . idf_escape($_GET["call"])), 0, 2); +$create = $mysql->result($mysql->query("SHOW CREATE " . (isset($_GET["callf"]) ? "FUNCTION" : "PROCEDURE") . " " . idf_escape($_GET["call"])), 2); preg_match("~\\($pattern(?:\\s*,$pattern)*~is", $create, $match); $in = array(); $out = array(); diff --git a/database.inc.php b/database.inc.php index d1519504..cd0549c7 100644 --- a/database.inc.php +++ b/database.inc.php @@ -37,7 +37,7 @@ if ($_POST) { $name = $_GET["db"]; $collate = array(); if (strlen($_GET["db"]) && ($result = $mysql->query("SHOW CREATE DATABASE " . idf_escape($_GET["db"])))) { - if (preg_match('~ COLLATE ([^ ]+)~', $mysql->result($result, 0, 1), $match)) { + if (preg_match('~ COLLATE ([^ ]+)~', $mysql->result($result, 1), $match)) { $collate = $match[1]; } $result->free(); diff --git a/download.inc.php b/download.inc.php index 3a6c7cbb..bb9e0497 100644 --- a/download.inc.php +++ b/download.inc.php @@ -1,3 +1,3 @@ result($mysql->query("SELECT " . idf_escape($_GET["field"]) . " FROM " . idf_escape($_GET["download"]) . " WHERE " . implode(" AND ", where()) . " LIMIT 1"), 0); +echo $mysql->result($mysql->query("SELECT " . idf_escape($_GET["field"]) . " FROM " . idf_escape($_GET["download"]) . " WHERE " . implode(" AND ", where()) . " LIMIT 1")); diff --git a/dump.inc.php b/dump.inc.php index 385c3b8b..e365bfcf 100644 --- a/dump.inc.php +++ b/dump.inc.php @@ -11,7 +11,7 @@ function dump($db) { $result = $mysql->query("SHOW $routine STATUS"); while ($row = $result->fetch_assoc()) { if (!strlen($_GET["db"]) || $row["Db"] === $_GET["db"]) { - $routines[$row["Db"]][] = $mysql->result($mysql->query("SHOW CREATE $routine " . idf_escape($row["Db"]) . "." . idf_escape($row["Name"])), 0, 2) . ";;\n\n"; + $routines[$row["Db"]][] = $mysql->result($mysql->query("SHOW CREATE $routine " . idf_escape($row["Db"]) . "." . idf_escape($row["Name"])), 2) . ";;\n\n"; } } $result->free(); @@ -21,7 +21,7 @@ function dump($db) { $result = $mysql->query("SHOW CREATE DATABASE " . idf_escape($db)); if ($result) { - echo $mysql->result($result, 0, 1) . ";\n"; + echo $mysql->result($result, 1) . ";\n"; $result->free(); } echo "USE " . idf_escape($db) . ";\n"; @@ -30,7 +30,7 @@ function dump($db) { while ($row = $result->fetch_assoc()) { $result1 = $mysql->query("SHOW CREATE TABLE " . idf_escape($row["Name"])); if ($result1) { - echo $mysql->result($result1, 0, 1) . ";\n"; + echo $mysql->result($result1, 1) . ";\n"; $result1->free(); if (isset($row["Engine"])) { $result1 = $mysql->query("SELECT * FROM " . idf_escape($row["Name"])); //! enum and set as numbers diff --git a/functions.inc.php b/functions.inc.php index 05b70e9b..098b1b76 100644 --- a/functions.inc.php +++ b/functions.inc.php @@ -74,7 +74,7 @@ function foreign_keys($table) { $return = array(); $result = $mysql->query("SHOW CREATE TABLE " . idf_escape($table)); if ($result) { - $create_table = $mysql->result($result, 0, 1); + $create_table = $mysql->result($result, 1); $result->free(); preg_match_all('~FOREIGN KEY \\((.+)\\) REFERENCES (?:`(.+)`\\.)?`(.+)` \\((.+)\\)~', $create_table, $matches, PREG_SET_ORDER); foreach ($matches as $match) { diff --git a/select.inc.php b/select.inc.php index 734aaff0..bfe4b5ef 100644 --- a/select.inc.php +++ b/select.inc.php @@ -94,7 +94,7 @@ for (var i=0; > i; i++) { if (!$result->num_rows) { echo "

" . lang('No rows.') . "

\n"; } else { - $found_rows = $mysql->result($mysql->query(" SELECT FOUND_ROWS()"), 0); // space for mysql.trace_mode + $found_rows = $mysql->result($mysql->query(" SELECT FOUND_ROWS()")); // space for mysql.trace_mode $foreign_keys = array(); foreach (foreign_keys($_GET["select"]) as $foreign_key) { foreach ($foreign_key[2] as $val) { diff --git a/view.inc.php b/view.inc.php index a4c5ce66..31ab8c2f 100644 --- a/view.inc.php +++ b/view.inc.php @@ -1,3 +1,3 @@ " . htmlspecialchars(preg_replace('~^.* AS ~U', '', $mysql->result($mysql->query("SHOW CREATE VIEW " . idf_escape($_GET["view"])), 0, 1))) . "\n"; +echo "
" . htmlspecialchars(preg_replace('~^.* AS ~U', '', $mysql->result($mysql->query("SHOW CREATE VIEW " . idf_escape($_GET["view"])), 1))) . "
\n";