Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Simplify work with NULL values in select

  • Loading branch information...
commit c4a57246ac86f299941b2afaae381ea12422646c 1 parent 20cf6d2
Jakub Vrána vrana authored
4 adminer/include/adminer.inc.php
@@ -184,9 +184,9 @@ function rowDescriptions($rows, $foreignKeys) {
184 184 * @return string
185 185 */
186 186 function selectVal($val, $link, $field) {
187   - $return = ($val != "<i>NULL</i>" && ereg("char|binary", $field["type"]) && !ereg("var", $field["type"]) ? "<code>$val</code>" : $val);
  187 + $return = ($val === null ? "<i>NULL</i>" : (ereg("char|binary", $field["type"]) && !ereg("var", $field["type"]) ? "<code>$val</code>" : $val));
188 188 if (ereg('blob|bytea|raw|file', $field["type"]) && !is_utf8($val)) {
189   - $return = lang('%d byte(s)', strlen(html_entity_decode($val, ENT_QUOTES)));
  189 + $return = lang('%d byte(s)', strlen($val));
190 190 }
191 191 return ($link ? "<a href='$link'>$return</a>" : $return);
192 192 }
14 adminer/select.inc.php
@@ -297,18 +297,18 @@
297 297 }
298 298 $link = "";
299 299 $val = $adminer->editVal($val, $field);
300   - if (!isset($val)) {
301   - $val = "<i>NULL</i>";
302   - } else {
  300 + if ($val !== null) {
303 301 if (ereg('blob|bytea|raw|file', $field["type"]) && $val != "") {
304 302 $link = h(ME . 'download=' . urlencode($TABLE) . '&field=' . urlencode($key) . $unique_idf);
305 303 }
306 304 if ($val === "") { // === - may be int
307 305 $val = "&nbsp;";
308   - } elseif ($text_length != "" && ereg('text|blob', $field["type"]) && is_utf8($val)) {
309   - $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
310   - } else {
311   - $val = h($val);
  306 + } elseif (is_utf8($val)) {
  307 + if ($text_length != "" && ereg('text|blob', $field["type"])) {
  308 + $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
  309 + } else {
  310 + $val = h($val);
  311 + }
312 312 }
313 313
314 314 if (!$link) { // link related items
1  changes.txt
@@ -7,6 +7,7 @@ MySQL: inform about disabled event_scheduler
7 7 SQLite: support binary data
8 8 PostgreSQL: approximate row count in table overview
9 9 Oracle: schema, processlist, table overview numbers
  10 +Simplify work with NULL values (customization)
10 11 Replace JSMin by better JavaScript minifier
11 12 Don't use AJAX links and forms
12 13 Ukrainian translation
2  editor/include/adminer.inc.php
@@ -159,7 +159,7 @@ function rowDescriptions($rows, $foreignKeys) {
159 159 }
160 160
161 161 function selectVal($val, $link, $field) {
162   - $return = ($val == "<i>NULL</i>" ? "&nbsp;" : $val);
  162 + $return = ($val === null ? "&nbsp;" : $val);
163 163 if (ereg('blob|bytea', $field["type"]) && !is_utf8($val)) {
164 164 $return = lang('%d byte(s)', strlen($val));
165 165 if (ereg("^(GIF|\xFF\xD8\xFF|\x89PNG\x0D\x0A\x1A\x0A)", $val)) { // GIF|JPG|PNG, getimagetype() works with filename

0 comments on commit c4a5724

Please sign in to comment.
Something went wrong with that request. Please try again.