mirror of
https://github.com/vrana/adminer.git
synced 2025-08-30 17:50:00 +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 bool
|
||||
*/
|
||||
function is_strict_mode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
function show_status() {
|
||||
return array();
|
||||
}
|
||||
|
@@ -50,7 +50,7 @@ if (!defined("DRIVER")) {
|
||||
$row = $result->fetch_array();
|
||||
return $row[$field];
|
||||
}
|
||||
|
||||
|
||||
function quote($string) {
|
||||
return "'" . $this->escape_string($string) . "'";
|
||||
}
|
||||
@@ -305,7 +305,7 @@ if (!defined("DRIVER")) {
|
||||
}
|
||||
return queries($prefix . implode(",\n", $values) . $suffix);
|
||||
}
|
||||
|
||||
|
||||
function slowQuery($query, $timeout) {
|
||||
if (min_version('5.7.8', '10.1.2')) {
|
||||
if (preg_match('~MariaDB~', $this->_conn->server_info)) {
|
||||
@@ -322,7 +322,7 @@ if (!defined("DRIVER")) {
|
||||
: $idf
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
function warnings() {
|
||||
$result = $this->_conn->query("SHOW WARNINGS");
|
||||
if ($result && $result->num_rows) {
|
||||
@@ -1056,6 +1056,19 @@ if (!defined("DRIVER")) {
|
||||
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
|
||||
* @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 bool
|
||||
*/
|
||||
function is_strict_mode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
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"
|
||||
FROM v$session sess LEFT OUTER JOIN v$sql sql
|
||||
|
@@ -860,6 +860,13 @@ AND typelem = 0"
|
||||
return get_key_vals("SHOW ALL");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
function is_strict_mode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
function process_list() {
|
||||
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 bool
|
||||
*/
|
||||
function is_strict_mode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
function show_status() {
|
||||
$return = array();
|
||||
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) {
|
||||
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);
|
||||
$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) {
|
||||
$val = stripcslashes(str_replace("''", "'", $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 $return;
|
||||
}
|
||||
|
||||
|
@@ -7,7 +7,7 @@
|
||||
* @license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
|
||||
*/
|
||||
class AdminerEnumOption {
|
||||
|
||||
|
||||
function editInput($table, $field, $attrs, $value) {
|
||||
if ($field["type"] == "enum") {
|
||||
$options = array();
|
||||
@@ -24,7 +24,9 @@ class AdminerEnumOption {
|
||||
$selected = "";
|
||||
}
|
||||
}
|
||||
$options[0] = lang('empty');
|
||||
if (!is_strict_mode()) {
|
||||
$options[0] = lang('empty');
|
||||
}
|
||||
preg_match_all("~'((?:[^']|'')*)'~", $field["length"], $matches);
|
||||
foreach ($matches[1] as $i => $val) {
|
||||
$val = stripcslashes(str_replace("''", "'", $val));
|
||||
@@ -36,5 +38,5 @@ class AdminerEnumOption {
|
||||
return "<select$attrs>" . optionlist($options, (string) $selected, 1) . "</select>"; // 1 - use keys
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user