mirror of
https://github.com/vrana/adminer.git
synced 2025-08-16 11:34:10 +02:00
Treat tinyint(1) as boolean
Use $SELF and ENT_QUOTES for compiled images git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@922 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
@@ -108,6 +108,7 @@ ORDER BY ORDINAL_POSITION"); //! requires MySQL 5
|
||||
}
|
||||
|
||||
function selectVal($val, $link, $field) {
|
||||
global $SELF; // used by compiled images
|
||||
$return = ($val == "<i>NULL</i>" ? " " : $val);
|
||||
if (ereg('blob|binary', $field["type"]) && !is_utf8($val)) {
|
||||
$return = lang('%d byte(s)', strlen($val));
|
||||
@@ -115,6 +116,9 @@ ORDER BY ORDINAL_POSITION"); //! requires MySQL 5
|
||||
$return = "<img src=\"$link\" alt='$return'>";
|
||||
}
|
||||
}
|
||||
if ($field["full_type"] == "tinyint(1)" && $return != " ") { // bool
|
||||
$return = '<img src="' . ($val ? "../adminer/plus.gif" : "../adminer/cross.gif") . '" alt="' . htmlspecialchars($val) . '">';
|
||||
}
|
||||
return ($link ? "<a href=\"$link\">$return</a>" : $return);
|
||||
}
|
||||
|
||||
@@ -268,34 +272,37 @@ ORDER BY ORDINAL_POSITION"); //! requires MySQL 5
|
||||
return (isset($_GET["select"]) ? array("orig" => lang('original')) : array()) + array("");
|
||||
}
|
||||
|
||||
function editInput($table, $field) {
|
||||
function editInput($table, $field, $attrs, $value) {
|
||||
global $dbh;
|
||||
$return = null;
|
||||
$foreign_keys = column_foreign_keys($table);
|
||||
foreach ((array) $foreign_keys[$field["field"]] as $foreign_key) {
|
||||
if (count($foreign_key["source"]) == 1) {
|
||||
$id = idf_escape($foreign_key["target"][0]);
|
||||
$name = $this->rowDescription($foreign_key["table"]);
|
||||
if (strlen($name) && $dbh->result($dbh->query("SELECT COUNT(*) FROM " . idf_escape($foreign_key["table"]))) <= 1000) { // optionlist with more than 1000 options would be too big
|
||||
if ($field["null"]) {
|
||||
$return = array();
|
||||
$result = $dbh->query("SELECT $id, $name FROM " . idf_escape($foreign_key["table"]) . " ORDER BY 2");
|
||||
if ($field["null"] || !$result->num_rows) { // empty <select> is not HTML-valid
|
||||
$return[""] = "";
|
||||
}
|
||||
$result = $dbh->query("SELECT $id, $name FROM " . idf_escape($foreign_key["table"]) . " ORDER BY 2");
|
||||
while ($row = $result->fetch_row()) {
|
||||
$return[$row[0]] = $row[1];
|
||||
}
|
||||
$result->free();
|
||||
break;
|
||||
return "<select$attrs>" . optionlist($return, $value, true) . "</select>";
|
||||
}
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
if ($field["full_type"] == "tinyint(1)") { // bool
|
||||
return '<input type="checkbox" value="' . htmlspecialchars($value ? $value : 1) . '"' . ($value ? ' checked="checked"' : '') . "$attrs>";
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
function processInput($field, $value, $function = "") {
|
||||
global $dbh;
|
||||
$return = $dbh->quote(ereg('date|timestamp', $field["type"]) ? preg_replace_callback('(' . preg_replace('~(\\\\\\$([0-9]))~', '(?P<p\\2>[0-9]+)', preg_quote(lang('$1-$3-$5'))) . ')', 'conversion_date', $value) : $value);
|
||||
if (!ereg('varchar|text', $field["type"]) && !strlen($value)) {
|
||||
if (!ereg('varchar|text', $field["type"]) && $field["full_type"] != "tinyint(1)" && !strlen($value)) {
|
||||
$return = "NULL";
|
||||
} elseif (ereg('date|time', $field["type"]) && $value == "CURRENT_TIMESTAMP") {
|
||||
$return = $value;
|
||||
|
Reference in New Issue
Block a user