From 02d6e7589173ac6e6c1e157a03f736895cd16614 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Thu, 17 Jul 2003 11:25:02 +0000 Subject: [PATCH] Fixed a MySQL 4.1 bug that appeared when inserting values into ENUM or SET fields. --- ChangeLog | 8 ++++++-- libraries/common.lib.php3 | 24 +++++++++++++++++++++++- tbl_change.php3 | 23 ++++++++--------------- 3 files changed, 37 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index a8aea197d..cd22a831b 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,10 +5,14 @@ phpMyAdmin - Changelog $Id$ $Source$ +2003-07-17 Alexander M. Turek + * tbl_change.php3, libraries/common.lib.php3: Fixed a MySQL 4.1 bug that + appeared when inserting values into ENUM or SET fields. + 2003-07-17 Garvin Hicking - * tbl_query_box.php3: Removed onsubmit() attribute of the noscript area. + * tbl_query_box.php3: Removed onsubmit() attribute of the noscript area. Thanks to andreas_e ;) - + 2003-07-16 Michal Cihar * lang/galician: Updated, thanks to Xosé Calvo. diff --git a/libraries/common.lib.php3 b/libraries/common.lib.php3 index b4070bea6..f4758adf9 100644 --- a/libraries/common.lib.php3 +++ b/libraries/common.lib.php3 @@ -240,7 +240,7 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} || (PMA_PHP_INT_VERSION >= 40005 && @ini_get('zlib.output_compression'))) { $cfg['OBGzip'] = FALSE; } - + // disable output-buffering (if set to 'auto') for IE6, else enable it. if (strtolower($cfg['OBGzip']) == 'auto') { if (PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER >= 6 && PMA_USR_BROWSER_VER < 7) { @@ -1581,6 +1581,28 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} return array($return_value, $unit); } // end of the 'PMA_formatByteDown' function + + + /** + * Extracts ENUM / SET options from a type definition string + * + * @param string The column type definition + * + * @return array The options or + * boolean FALSE in case of an error. + * + * @author rabus + */ + function PMA_getEnumSetOptions($type_def) { + $open = strpos($type_def, '('); + $close = strpos($type_def, ')'); + if (!$open || !$close) { + return FALSE; + } + $options = substr($type_def, $open + 2, $close - $open - 3); + $options = explode('\',\'', $options); + return $options; + } // end of the 'PMA_getEnumSetOptions' function /** diff --git a/tbl_change.php3 b/tbl_change.php3 index fbff5bbd0..975c81e32 100755 --- a/tbl_change.php3 +++ b/tbl_change.php3 @@ -477,9 +477,7 @@ for ($i = 0; $i < $fields_cnt; $i++) { } } else if ($type == 'enum') { - $enum = str_replace('enum(', '', $row_table_def['Type']); - $enum = ereg_replace('\\)$', '', $enum); - $enum = explode('\',\'', substr($enum, 1, -1)); + $enum = PMA_getEnumSetOptions($row_table_def['Type']); $enum_cnt = count($enum); ?> @@ -538,9 +536,7 @@ for ($i = 0; $i < $fields_cnt; $i++) { echo "\n"; } else if ($type == 'set') { - $set = str_replace('set(', '', $row_table_def['Type']); - $set = ereg_replace('\)$', '', $set); - $set = explode(',', $set); + $set = PMA_getEnumSetOptions($row_table_def['Type']); if (isset($vset)) { unset($vset); @@ -548,7 +544,8 @@ for ($i = 0; $i < $fields_cnt; $i++) { for ($vals = explode(',', $data); list($t, $k) = each($vals);) { $vset[$k] = 1; } - $size = min(4, count($set)); + $countset = count($set); + $size = min(4, $countset); ?> @@ -557,17 +554,13 @@ for ($i = 0; $i < $fields_cnt; $i++) {