Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Properly display value of type bit (from MySQL) #28

Closed
wants to merge 1 commit into from

2 participants

@juzna

MySQL has column type of bit which returns binary zero (\0) or binary one (\1), which is not properly displayed - both of these chars aren't renderable and thus appear as empty column.

@juzna

Btw this PR isn't probably the best way of solving this issue, but it's the best I can do with my brief knowledge of adminer's internals. And it works for me ;)

@juzna

It looks like a bug in PHP 5.3: https://bugs.php.net/bug.php?id=63244
Seems to be fine in PHP 5.4 as it is right now in master.

@vrana
Owner

There's also bit(2) and more so \1 is not the only possible value. With bit(6), it's possible to get \x30 which is 0.

@juzna

Yep, this seemed like a great idea at first but then I realised how stupid it is.
fail

@juzna juzna closed this
@juzna juzna deleted the juzna:feature/mysql-bit-support branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 8, 2012
  1. @juzna
This page is out of date. Refresh to see the latest.
View
5 adminer/include/adminer.inc.php
@@ -205,6 +205,11 @@ function selectVal($val, $link, $field) {
* @return string
*/
function editVal($val, $field) {
+ if ($val === "\0") {
+ return '0';
+ } elseif ($val === "\1") {
+ return '1';
+ }
return $val;
}
View
4 adminer/include/editing.inc.php
@@ -57,6 +57,10 @@ function select($result, $connection2 = null, $href = "", $orgtables = array())
foreach ($row as $key => $val) {
if ($val === null) {
$val = "<i>NULL</i>";
+ } elseif ($val === "\0") {
+ $val = "<i>0</i>";
+ } elseif ($val === "\1") {
+ $val = "<i>1</i>";
} elseif ($blobs[$key] && !is_utf8($val)) {
$val = "<i>" . lang('%d byte(s)', strlen($val)) . "</i>"; //! link to download
} elseif (!strlen($val)) { // strlen - SQLite can return int
View
4 editor/include/adminer.inc.php
@@ -187,6 +187,10 @@ function selectVal($val, $link, $field) {
function editVal($val, $field) {
if (ereg('date|timestamp', $field["type"]) && $val !== null) {
return preg_replace('~^(\\d{2}(\\d+))-(0?(\\d+))-(0?(\\d+))~', lang('$1-$3-$5'), $val);
+ } elseif ($val === "\0") {
+ return 'No';
+ } elseif ($val === "\1") {
+ return 'Yes';
}
return $val;
}
Something went wrong with that request. Please try again.