]> git.joonet.de Git - adminer.git/commitdiff
Simplify work with NULL values in select
authorJakub Vrana <jakub@vrana.cz>
Mon, 14 May 2012 06:24:39 +0000 (23:24 -0700)
committerJakub Vrana <jakub@vrana.cz>
Mon, 14 May 2012 06:24:39 +0000 (23:24 -0700)
adminer/include/adminer.inc.php
adminer/select.inc.php
changes.txt
editor/include/adminer.inc.php

index a46461dd7cbd4dabaaeb72a361de9b0be13d2b9f..dd8ff195ae2bd7337af77d9f1cca48270601f8a8 100644 (file)
@@ -184,9 +184,9 @@ username.form['driver'].onchange();
        * @return string
        */
        function selectVal($val, $link, $field) {
-               $return = ($val != "<i>NULL</i>" && ereg("char|binary", $field["type"]) && !ereg("var", $field["type"]) ? "<code>$val</code>" : $val);
+               $return = ($val === null ? "<i>NULL</i>" : (ereg("char|binary", $field["type"]) && !ereg("var", $field["type"]) ? "<code>$val</code>" : $val));
                if (ereg('blob|bytea|raw|file', $field["type"]) && !is_utf8($val)) {
-                       $return = lang('%d byte(s)', strlen(html_entity_decode($val, ENT_QUOTES)));
+                       $return = lang('%d byte(s)', strlen($val));
                }
                return ($link ? "<a href='$link'>$return</a>" : $return);
        }
index e0d994c56134d09148100b61835857a2713bd385..3a5a3e41a3b28bf5b43e4e160af215f74e2e3ad0 100644 (file)
@@ -297,18 +297,18 @@ if (!$columns) {
                                                }
                                                $link = "";
                                                $val = $adminer->editVal($val, $field);
-                                               if (!isset($val)) {
-                                                       $val = "<i>NULL</i>";
-                                               } else {
+                                               if ($val !== null) {
                                                        if (ereg('blob|bytea|raw|file', $field["type"]) && $val != "") {
                                                                $link = h(ME . 'download=' . urlencode($TABLE) . '&field=' . urlencode($key) . $unique_idf);
                                                        }
                                                        if ($val === "") { // === - may be int
                                                                $val = "&nbsp;";
-                                                       } elseif ($text_length != "" && ereg('text|blob', $field["type"]) && is_utf8($val)) {
-                                                               $val = shorten_utf8($val, max(0, +$text_length)); // usage of LEFT() would reduce traffic but complicate query - expected average speedup: .001 s VS .01 s on local network
-                                                       } else {
-                                                               $val = h($val);
+                                                       } elseif (is_utf8($val)) {
+                                                               if ($text_length != "" && ereg('text|blob', $field["type"])) {
+                                                                       $val = shorten_utf8($val, max(0, +$text_length)); // usage of LEFT() would reduce traffic but complicate query - expected average speedup: .001 s VS .01 s on local network
+                                                               } else {
+                                                                       $val = h($val);
+                                                               }
                                                        }
                                                        
                                                        if (!$link) { // link related items
index 4ee0aea5fa445c0f49f2d25fd296c8fdeb437d50..0841cc818c73b20e8572ffa0f8fe9583f0041477 100644 (file)
@@ -7,6 +7,7 @@ MySQL: inform about disabled event_scheduler
 SQLite: support binary data
 PostgreSQL: approximate row count in table overview
 Oracle: schema, processlist, table overview numbers
+Simplify work with NULL values (customization)
 Replace JSMin by better JavaScript minifier
 Don't use AJAX links and forms
 Ukrainian translation
index 11d40d540cc2ee64ae826aa83ef2b68ab9191b5a..1830851eeab7712ec2c963e18f5b160c42b94b7b 100644 (file)
@@ -159,7 +159,7 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
        }
        
        function selectVal($val, $link, $field) {
-               $return = ($val == "<i>NULL</i>" ? "&nbsp;" : $val);
+               $return = ($val === null ? "&nbsp;" : $val);
                if (ereg('blob|bytea', $field["type"]) && !is_utf8($val)) {
                        $return = lang('%d byte(s)', strlen($val));
                        if (ereg("^(GIF|\xFF\xD8\xFF|\x89PNG\x0D\x0A\x1A\x0A)", $val)) { // GIF|JPG|PNG, getimagetype() works with filename