From 988a29fca10c92e87d9589499899890682b8163c Mon Sep 17 00:00:00 2001 From: jakubvrana Date: Tue, 28 Jul 2009 12:56:38 +0000 Subject: [PATCH] Don't use aggregation functions in unique_idf Single checkbox can edit multiple rows with aggregation git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@926 7c3ca157-0c34-0410-bff1-cbf682f78f5c --- adminer/edit.inc.php | 6 +++--- adminer/include/adminer.inc.php | 2 +- adminer/include/functions.inc.php | 4 +++- adminer/select.inc.php | 6 +++--- changes.txt | 4 +++- todo.txt | 3 +-- 6 files changed, 14 insertions(+), 11 deletions(-) diff --git a/adminer/edit.inc.php b/adminer/edit.inc.php index a5ab4ede..e556c038 100644 --- a/adminer/edit.inc.php +++ b/adminer/edit.inc.php @@ -1,6 +1,6 @@ $field) { if ((isset($_GET["default"]) ? $field["auto_increment"] || ereg('text|blob', $field["type"]) : !isset($field["privileges"][$update ? "update" : "insert"])) || !strlen($adminer->fieldName($field))) { @@ -38,7 +38,7 @@ if ($_POST && !$error && !isset($_GET["select"])) { $table_name = $adminer->tableName(table_status($_GET["edit"])); page_header( - (isset($_GET["default"]) ? lang('Default values') : ($_GET["where"] || (isset($_GET["select"]) && !$_POST["clone"]) ? lang('Edit') : lang('Insert'))), + (isset($_GET["default"]) ? lang('Default values') : ($update ? lang('Edit') : lang('Insert'))), $error, array((isset($_GET["default"]) ? "table" : "select") => array($_GET["edit"], $table_name)), $table_name diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php index 4cde3c0d..a7c56d45 100644 --- a/adminer/include/adminer.inc.php +++ b/adminer/include/adminer.inc.php @@ -455,7 +455,7 @@ class Adminer { echo "

\n"; while ($row = $result->fetch_row()) { echo '' . lang('select') . ' '; - echo '' . $this->tableName(array("Name" => $row[0])) . "
\n"; //! Adminer::table_name may work with full table status + echo '' . $this->tableName(array("Name" => $row[0])) . "
\n"; //! Adminer::tableName may work with full table status } } $result->free(); diff --git a/adminer/include/functions.inc.php b/adminer/include/functions.inc.php index 2b92a820..aeda28de 100644 --- a/adminer/include/functions.inc.php +++ b/adminer/include/functions.inc.php @@ -69,7 +69,9 @@ function unique_idf($row, $indexes) { } $return = array(); foreach ($row as $key => $val) { - $return[] = (isset($val) ? urlencode("where[" . bracket_escape($key) . "]") . "=" . urlencode($val) : "null%5B%5D=" . urlencode($key)); + if (!preg_match('~^(COUNT\\((\\*|(DISTINCT )?`(?:[^`]+|``)+`)\\)|(AVG|GROUP_CONCAT|MAX|MIN|SUM)\\(`(?:[^`]+|``)+`\\))$~', $key)) { //! columns looking like functions + $return[] = (isset($val) ? urlencode("where[" . bracket_escape($key) . "]") . "=" . urlencode($val) : "null%5B%5D=" . urlencode($key)); + } } return $return; } diff --git a/adminer/select.inc.php b/adminer/select.inc.php index e503886e..429516dc 100644 --- a/adminer/select.inc.php +++ b/adminer/select.inc.php @@ -78,7 +78,7 @@ if ($_POST && !$error) { } else { foreach ((array) $_POST["check"] as $val) { // where is not unique so OR can't be used - $result = queries($command . "\nWHERE " . where_check($val) . "\nLIMIT 1"); + $result = queries($command . "\nWHERE " . where_check($val) . (count($group) < count($select) ? "" : "\nLIMIT 1")); if (!$result) { break; } @@ -184,13 +184,13 @@ if (!$columns) { if (strlen($name)) { $order++; $names[$key] = $name; - echo '' . apply_sql_function($val["fun"], $name) . ""; //! order by function can collide with column name like min(`id`) + echo '' . apply_sql_function($val["fun"], $name) . ""; //! columns looking like functions } next($select); } echo ($backward_keys ? "" . lang('Relations') : "") . "\n"; foreach ($descriptions as $n => $row) { - $unique_idf = implode('&', unique_idf($rows[$n], $indexes)); //! don't use aggregation functions + $unique_idf = implode('&', unique_idf($rows[$n], $indexes)); echo '' . (count($select) != count($group) || information_schema($_GET["db"]) ? '' : ' ' . lang('edit') . ''); foreach ($row as $key => $val) { if (isset($names[$key])) { diff --git a/changes.txt b/changes.txt index 414646c6..d64680a3 100644 --- a/changes.txt +++ b/changes.txt @@ -5,7 +5,9 @@ Create single column foreign key in table structure Table relations (Editor) Send e-mails (Editor) Display images in blob (Editor) -Separate types to groups in table creation +Localize date (Editor) +Treat tinyint(1) as bool (Editor) +Divide types to groups in table creation Link e-mails in select Show type in field name title (thanks to Jakub Sochor) Preselect now() for timestamp columns (thanks to paranoiq) diff --git a/todo.txt b/todo.txt index 5fd53d7c..47d24660 100644 --- a/todo.txt +++ b/todo.txt @@ -16,9 +16,8 @@ Table status cache - SHOW TABLE STATUS is slow with big InnoDB tables Download external files (version checker and JUSH) from trusted HTTPS if Adminer runs in HTTPS (mixed-content warning) ? Ability to select external style - list downloaded by JavaScript ? Column and table names auto-completition in SQL textarea -? Save token also to cookie - for session expiration and login in other window ? Save uploaded files after error to session variable instead of hidden field -? Aliasing of built-in functions can save 7 KB, substitution of $_GET and friends can save 2 KB, remove of base64_decode() + using chars 127-255 in minification can save 1 KB, JS packer can save 1 KB +? Aliasing of built-in functions can save 7 KB, function minification can save 7 KB, substitution of $_GET and friends can save 2 KB, remove of base64_decode() + using chars 127-255 in minification can save 1 KB, JS packer can save 1 KB ? AJAX editing - select page has all data to display edit form Editor: