]> git.joonet.de Git - adminer.git/commitdiff
Search in all tables
authorjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Tue, 16 Feb 2010 14:35:32 +0000 (14:35 +0000)
committerjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Tue, 16 Feb 2010 14:35:32 +0000 (14:35 +0000)
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1313 7c3ca157-0c34-0410-bff1-cbf682f78f5c

adminer/db.inc.php
adminer/dump.inc.php
adminer/include/functions.inc.php
changes.txt
editor/db.inc.php
todo.txt

index a9fcfa693cf53bbaae139898a763713ed7514997..88de70ecea2c8b36263fb97619ba4e79bcca3055 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 $tables_views = array_merge((array) $_POST["tables"], (array) $_POST["views"]);
 
-if ($tables_views && !$error) {
+if ($tables_views && !$error && !$_POST["search"]) {
        $result = true;
        $message = "";
        if (count($_POST["tables"]) > 1 && ($_POST["drop"] || $_POST["truncate"])) {
@@ -47,6 +47,12 @@ if (!$table_status) {
        echo "<p class='message'>" . lang('No tables.') . "\n";
 } else {
        echo "<form action='' method='post'>\n";
+       echo "<p><input name='query' value='" . h($_POST["query"]) . "'> <input type='submit' name='search' value='" . lang('Search') . "'>\n";
+       if ($_POST["search"] && $_POST["query"] != "") {
+               $_GET["where"][0]["op"] = "LIKE";
+               $_GET["where"][0]["val"] = "%$_POST[query]%";
+               search_tables();
+       }
        echo "<table cellspacing='0' class='nowrap' onclick='tableClick(event);'>\n";
        echo '<thead><tr class="wrap"><td><input id="check-all" type="checkbox" onclick="formCheck(this, /^(tables|views)\[/);"><th>' . lang('Table') . '<td>' . lang('Engine') . '<td>' . lang('Collation') . '<td>' . lang('Data Length') . '<td>' . lang('Index Length') . '<td>' . lang('Data Free') . '<td>' . lang('Auto Increment') . '<td>' . lang('Rows') . '<td>' . lang('Comment') . "</thead>\n";
        $sums = array();
index c2440eecf85206323fd0c264fdface97a98af6d6..143fb20cca22f8dbdacf2f8d9e61e234703b45f8 100644 (file)
@@ -147,7 +147,7 @@ if ($connection->server_info >= 5) {
        $db_style[] = 'CREATE+ALTER';
        $table_style[] = 'CREATE+ALTER';
 }
-echo "<tr><th>" . lang('Output') . "<td><input type='hidden' name='token' value='$token'>" . $adminer->dumpOutput(0) . "\n"; // token is not needed but checked in bootstrap for all POST data
+echo "<tr><th>" . lang('Output') . "<td><input type='hidden' name='token' value='$token'>" . $adminer->dumpOutput(0) . "\n"; // token is not needed but checked in bootstrap for all POST data //! read from cookie
 echo "<tr><th>" . lang('Format') . "<td>" . $adminer->dumpFormat(0) . "\n";
 echo "<tr><th>" . lang('Database') . "<td>" . html_select('db_style', $db_style, (DB != "" ? '' : 'CREATE'));
 if ($connection->server_info >= 5) {
index 888d46e43b6e0fe0d1a07771a08c734839eb42d6..e370f0879fdbf17471538ac960e2da05761a34b9 100644 (file)
@@ -479,6 +479,30 @@ function process_input($field) {
        }
 }
 
+/** Print results of search in all tables
+* @uses $_GET["where"][0]
+* @uses $_POST["tables"]
+* @return null
+*/
+function search_tables() {
+       global $adminer, $connection;
+       $found = false;
+       foreach (table_status() as $table => $table_status) {
+               $name = $adminer->tableName($table_status);
+               if (isset($table_status["Engine"]) && $name != "" && (!$_POST["tables"] || in_array($table, $_POST["tables"]))) {
+                       $result = $connection->query($q = "SELECT 1 FROM " . idf_escape($table) . " WHERE " . implode(" AND ", $adminer->selectSearchProcess(fields($table), array())) . " LIMIT 1");
+                       if ($result->num_rows) {
+                               if (!$found) {
+                                       echo "<ul>\n";
+                                       $found = true;
+                               }
+                               echo "<li><a href='" . h(ME . "select=" . urlencode($table) . "&where[0][op]=" . urlencode($_GET["where"][0]["op"]) . "&where[0][val]=" . urlencode($_GET["where"][0]["val"])) . "'>" . h($name) . "</a>\n";
+                       }
+               }
+       }
+       echo ($found ? "</ul>" : "<p class='message'>" . lang('No tables.')) . "\n";
+}
+
 /** Print CSV row
 * @param array
 * @return null
index 9efb18f646a2344580da967dfc04820adaa19f2c..c1777779cb551718c9b3a4f672da150fa1934fd8 100644 (file)
@@ -1,6 +1,6 @@
 Adminer 2.3.0-dev:
 Support for permanent login (customization required)
-Search in all tables (Editor)
+Search in all tables
 Show status variables
 Print sums in tables overview
 Add Delete button to Edit page (regression from 2.0.0)
index 2385fb75b923b983c851ba08f1051c712d999d34..ce13ce9bbb5870088c62730ede7df01773f2a7f5 100644 (file)
@@ -4,24 +4,10 @@ page_header(lang('Server'), "", null);
 ?>
 <form action=""><p>
 <?php echo SID_FORM; ?>
-<input name="where[][val]" value="<?php echo h($_GET["where"][0]["val"]); ?>">
+<input name="where[0][val]" value="<?php echo h($_GET["where"][0]["val"]); ?>">
 <input type="submit" value="<?php echo lang('Search'); ?>" />
 </form>
 <?php
-if ($_GET["where"]) {
-       $found = false;
-       foreach (table_status() as $table => $table_status) {
-               $name = $adminer->tableName($table_status);
-               if (isset($table_status["Engine"]) && $name != "") {
-                       $result = $connection->query("SELECT 1 FROM " . idf_escape($table) . " WHERE " . implode(" AND ", $adminer->selectSearchProcess(fields($table), array())) . " LIMIT 1");
-                       if ($result->num_rows) {
-                               if (!$found) {
-                                       echo "<ul>\n";
-                                       $found = true;
-                               }
-                               echo "<li><a href='" . h(ME . "select=" . urlencode($table) . "&where[][val]=" . urlencode($_GET["where"][0]["val"])) . "'>" . h($name) . "</a>\n";
-                       }
-               }
-       }
-       echo ($found ? "</ul>" : "<p class='message'>" . lang('No tables.')) . "\n";
+if ($_GET["where"][0]["val"] != "") {
+       search_tables();
 }
index 348b0e63eff3bbd46c5584c4afda7547fc92d1fd..706e8eb81818e738354ec4a0580349d321b36ad4 100644 (file)
--- a/todo.txt
+++ b/todo.txt
@@ -1,7 +1,6 @@
 MySQL 5 BIT data type
 Transactions in export
 Create view and routine options
-Function to fix database encoding - http://php.vrana.cz/prevod-kodovani-mysql.php
 Highlight SQL textarea - may use external CodePress
 Mass editation of individual rows
 Offer enum and set items in search - whisperer
@@ -9,6 +8,7 @@ Variables editation, especially timezone
 Use event $intervals + microseconds in relative date functions
 Optionally check IP address
 Disable spell checking in SQL textareas - spellcheck="false"
+Accept Tab in SQL textareas, Ctrl+Enter to send form
 Blob download and image display in edit form (important for Editor with hidden fields in select)
 Add title to Logout, edit (in select) and select (in menu) in style "hever"
 ? Column and table names auto-completition in SQL textarea