]> git.joonet.de Git - adminer.git/commitdiff
Don't use aggregation functions in unique_idf
authorjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Tue, 28 Jul 2009 12:56:38 +0000 (12:56 +0000)
committerjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Tue, 28 Jul 2009 12:56:38 +0000 (12:56 +0000)
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
adminer/include/adminer.inc.php
adminer/include/functions.inc.php
adminer/select.inc.php
changes.txt
todo.txt

index a5ab4ede740e095b006a45c56eec3d23c5d951a2..e556c038d3f242c992ce73e314ca49661b357010 100644 (file)
@@ -1,6 +1,6 @@
 <?php
-$where = (isset($_GET["select"]) ? (count($_POST["check"]) == 1 ? where_check($_POST["check"][0]) : "") : where($_GET));
-$update = ($where && !$_POST["clone"]);
+$where = (isset($_GET["select"]) ? "" : where($_GET));
+$update = ($where || $_POST["edit"]);
 $fields = fields($_GET["edit"]);
 foreach ($fields as $name => $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
index 4cde3c0d2e497391c17afc8f6f3bef1ccb9f95c0..a7c56d45965d4c0b28a3decd226cc06018e4c206 100644 (file)
@@ -455,7 +455,7 @@ class Adminer {
                                        echo "<p>\n";
                                        while ($row = $result->fetch_row()) {
                                                echo '<a href="' . htmlspecialchars($SELF) . 'select=' . urlencode($row[0]) . '">' . lang('select') . '</a> ';
-                                               echo '<a href="' . htmlspecialchars($SELF) . 'table=' . urlencode($row[0]) . '">' . $this->tableName(array("Name" => $row[0])) . "</a><br>\n"; //! Adminer::table_name may work with full table status
+                                               echo '<a href="' . htmlspecialchars($SELF) . 'table=' . urlencode($row[0]) . '">' . $this->tableName(array("Name" => $row[0])) . "</a><br>\n"; //! Adminer::tableName may work with full table status
                                        }
                                }
                                $result->free();
index 2b92a8209c5f813e3661e8d7568c5b0ac72d7716..aeda28de4169933fcca7cf6521ebe85e3e2241ce 100644 (file)
@@ -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;
 }
index e503886e6d2b1d8679f01b4109ada7d38bb19a90..429516dc909bd9f5883e5d637864d9cb408aa96b 100644 (file)
@@ -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 '<th><a href="' . htmlspecialchars(remove_from_uri('(order|desc)[^=]*') . '&order%5B0%5D=' . urlencode($key) . ($_GET["order"] == array($key) && !$_GET["desc"][0] ? '&desc%5B0%5D=1' : '')) . '">' . apply_sql_function($val["fun"], $name) . "</a>"; //! order by function can collide with column name like min(`id`)
+                                       echo '<th><a href="' . htmlspecialchars(remove_from_uri('(order|desc)[^=]*') . '&order%5B0%5D=' . urlencode($key) . ($_GET["order"] == array($key) && !$_GET["desc"][0] ? '&desc%5B0%5D=1' : '')) . '">' . apply_sql_function($val["fun"], $name) . "</a>"; //! columns looking like functions
                                }
                                next($select);
                        }
                        echo ($backward_keys ? "<th>" . lang('Relations') : "") . "</thead>\n";
                        foreach ($descriptions as $n => $row) {
-                               $unique_idf = implode('&amp;', unique_idf($rows[$n], $indexes)); //! don't use aggregation functions
+                               $unique_idf = implode('&amp;', unique_idf($rows[$n], $indexes));
                                echo '<tr' . odd() . '><td><input type="checkbox" name="check[]" value="' . $unique_idf . '" onclick="this.form[\'all\'].checked = false; form_uncheck(\'all-page\');">' . (count($select) != count($group) || information_schema($_GET["db"]) ? '' : ' <a href="' . htmlspecialchars($SELF) . 'edit=' . urlencode($_GET['select']) . '&amp;' . $unique_idf . '">' . lang('edit') . '</a>');
                                foreach ($row as $key => $val) {
                                        if (isset($names[$key])) {
index 414646c6d6e0f341ac306f6e6b847a9492508041..d64680a3fcdb2868d4dba835cdc4cb59c03638ea 100644 (file)
@@ -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)
index 5fd53d7c6e420dbd70cb76ef8b620708ee7009c4..47d246602ee8c3188386c96b41e13427dfa62e2c 100644 (file)
--- 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: