Search in all tables

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1313 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
jakubvrana 2010-02-16 14:35:32 +00:00
parent cf98a3344b
commit db07325ed6
6 changed files with 37 additions and 21 deletions

View 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();

View 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) {

View 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

View 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)

View 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();
}

View file

@ -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