Fixed a MySQL 4.1 bug that appeared when inserting values into ENUM or SET fields.

This commit is contained in:
Alexander M. Turek
2003-07-17 11:25:02 +00:00
parent fd7fc125cd
commit 02d6e75891
3 changed files with 37 additions and 18 deletions

View File

@@ -5,10 +5,14 @@ phpMyAdmin - Changelog
$Id$
$Source$
2003-07-17 Alexander M. Turek <rabus@users.sourceforge.net>
* 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 <me@supergarv.de>
* 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 <nijel@users.sourceforge.net>
* lang/galician: Updated, thanks to Xos<6F> Calvo.

View File

@@ -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
/**

View File

@@ -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);
?>
<td bgcolor="<?php echo $bgcolor; ?>">
@@ -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);
?>
<td bgcolor="<?php echo $bgcolor; ?>">
<?php echo $backup_field . "\n"; ?>
@@ -557,17 +554,13 @@ for ($i = 0; $i < $fields_cnt; $i++) {
<select name="field_<?php echo md5($field); ?>[]" size="<?php echo $size; ?>" multiple="multiple" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo ($i + 1); ?>" id="field_<?php echo $i; ?>_3">
<?php
echo "\n";
$countset = count($set);
for ($j = 0; $j < $countset;$j++) {
$subset = substr($set[$j], 1, -1);
// Removes automatic MySQL escape format
$subset = str_replace('\'\'', '\'', str_replace('\\\\', '\\', $subset));
for ($j = 0; $j < $countset; $j++) {
echo ' ';
echo '<option value="'. htmlspecialchars($subset) . '"';
if (isset($vset[$subset]) && $vset[$subset]) {
echo '<option value="'. htmlspecialchars($set[$j]) . '"';
if (isset($vset[$set[$j]]) && $vset[$set[$j]]) {
echo ' selected="selected"';
}
echo '>' . htmlspecialchars($subset) . '</option>' . "\n";
echo '>' . htmlspecialchars($set[$j]) . '</option>' . "\n";
} // end for
?>
</select>