mirror of
https://github.com/vrana/adminer.git
synced 2025-09-01 10:23:28 +02:00
MySQL: Do not show 'empty' enum value in strict mode
This commit is contained in:
@@ -630,6 +630,13 @@ WHERE sys1.xtype = 'TR' AND sys2.name = " . q($table)
|
|||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function is_strict_mode() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
function show_status() {
|
function show_status() {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
@@ -1056,6 +1056,19 @@ if (!defined("DRIVER")) {
|
|||||||
return get_key_vals("SHOW VARIABLES");
|
return get_key_vals("SHOW VARIABLES");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function is_strict_mode() {
|
||||||
|
static $strictMode = null;
|
||||||
|
|
||||||
|
if ($strictMode === null) {
|
||||||
|
$strictMode = (bool)preg_match('~STRICT_(TRANS|ALL)_TABLES~', get_key_vals("SHOW VARIABLES LIKE 'sql_mode'")["sql_mode"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $strictMode;
|
||||||
|
}
|
||||||
|
|
||||||
/** Get process list
|
/** Get process list
|
||||||
* @return array ($row)
|
* @return array ($row)
|
||||||
*/
|
*/
|
||||||
|
@@ -486,6 +486,13 @@ AND c_src.TABLE_NAME = " . q($table);
|
|||||||
return get_key_vals('SELECT name, display_value FROM v$parameter');
|
return get_key_vals('SELECT name, display_value FROM v$parameter');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function is_strict_mode() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
function process_list() {
|
function process_list() {
|
||||||
return get_rows('SELECT sess.process AS "process", sess.username AS "user", sess.schemaname AS "schema", sess.status AS "status", sess.wait_class AS "wait_class", sess.seconds_in_wait AS "seconds_in_wait", sql.sql_text AS "sql_text", sess.machine AS "machine", sess.port AS "port"
|
return get_rows('SELECT sess.process AS "process", sess.username AS "user", sess.schemaname AS "schema", sess.status AS "status", sess.wait_class AS "wait_class", sess.seconds_in_wait AS "seconds_in_wait", sql.sql_text AS "sql_text", sess.machine AS "machine", sess.port AS "port"
|
||||||
FROM v$session sess LEFT OUTER JOIN v$sql sql
|
FROM v$session sess LEFT OUTER JOIN v$sql sql
|
||||||
|
@@ -860,6 +860,13 @@ AND typelem = 0"
|
|||||||
return get_key_vals("SHOW ALL");
|
return get_key_vals("SHOW ALL");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function is_strict_mode() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
function process_list() {
|
function process_list() {
|
||||||
return get_rows("SELECT * FROM pg_stat_activity ORDER BY " . (min_version(9.2) ? "pid" : "procpid"));
|
return get_rows("SELECT * FROM pg_stat_activity ORDER BY " . (min_version(9.2) ? "pid" : "procpid"));
|
||||||
}
|
}
|
||||||
|
@@ -764,6 +764,13 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
|||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function is_strict_mode() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
function show_status() {
|
function show_status() {
|
||||||
$return = array();
|
$return = array();
|
||||||
foreach (get_vals("PRAGMA compile_options") as $option) {
|
foreach (get_vals("PRAGMA compile_options") as $option) {
|
||||||
|
@@ -914,13 +914,16 @@ function column_foreign_keys($table) {
|
|||||||
*/
|
*/
|
||||||
function enum_input($type, $attrs, $field, $value, $empty = null) {
|
function enum_input($type, $attrs, $field, $value, $empty = null) {
|
||||||
global $adminer;
|
global $adminer;
|
||||||
|
|
||||||
|
$return = ($empty !== null && !is_strict_mode() ? "<label><input type='$type'$attrs value='$empty'" . ((is_array($value) ? in_array($empty, $value) : $value === 0) ? " checked" : "") . "><i>" . lang('empty') . "</i></label>" : "");
|
||||||
|
|
||||||
preg_match_all("~'((?:[^']|'')*)'~", $field["length"], $matches);
|
preg_match_all("~'((?:[^']|'')*)'~", $field["length"], $matches);
|
||||||
$return = ($empty !== null ? "<label><input type='$type'$attrs value='$empty'" . ((is_array($value) ? in_array($empty, $value) : $value === 0) ? " checked" : "") . "><i>" . lang('empty') . "</i></label>" : "");
|
|
||||||
foreach ($matches[1] as $i => $val) {
|
foreach ($matches[1] as $i => $val) {
|
||||||
$val = stripcslashes(str_replace("''", "'", $val));
|
$val = stripcslashes(str_replace("''", "'", $val));
|
||||||
$checked = (is_int($value) ? $value == $i+1 : (is_array($value) ? in_array($i+1, $value) : $value === $val));
|
$checked = (is_int($value) ? $value == $i+1 : (is_array($value) ? in_array($i+1, $value) : $value === $val));
|
||||||
$return .= " <label><input type='$type'$attrs value='" . ($i+1) . "'" . ($checked ? ' checked' : '') . '>' . h($adminer->editVal($val, $field)) . '</label>';
|
$return .= " <label><input type='$type'$attrs value='" . ($i+1) . "'" . ($checked ? ' checked' : '') . '>' . h($adminer->editVal($val, $field)) . '</label>';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -24,7 +24,9 @@ class AdminerEnumOption {
|
|||||||
$selected = "";
|
$selected = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$options[0] = lang('empty');
|
if (!is_strict_mode()) {
|
||||||
|
$options[0] = lang('empty');
|
||||||
|
}
|
||||||
preg_match_all("~'((?:[^']|'')*)'~", $field["length"], $matches);
|
preg_match_all("~'((?:[^']|'')*)'~", $field["length"], $matches);
|
||||||
foreach ($matches[1] as $i => $val) {
|
foreach ($matches[1] as $i => $val) {
|
||||||
$val = stripcslashes(str_replace("''", "'", $val));
|
$val = stripcslashes(str_replace("''", "'", $val));
|
||||||
|
Reference in New Issue
Block a user