check for field type before doing charset conversion

This commit is contained in:
Michal Čihař
2003-03-20 19:50:48 +00:00
parent 713ee98a1e
commit 4f6bfb8d3b
2 changed files with 37 additions and 7 deletions

View File

@@ -10,6 +10,8 @@ $Source$
2003-03-20 Michal Cihar <nijel@users.sourceforge.net>
* lang/indonesian: Updated, thanks again to Rachim Tamsjadi.
* libraries/mysql_wrappers.lib.php3: Fix for bug #705531 - check for field
type when doing charset conversion.
2003-03-19 Garvin Hicking <me@supergarv.de>
* tbl_change.php3, tbl_query_box.php3, tbl_replace_fields.php3:

View File

@@ -30,10 +30,39 @@ if (!defined('PMA_MYSQL_WRAPPERS_LIB_INCLUDED')){
}
function PMA_mysql_fetch_array($result, $type = FALSE) {
global $cfg, $allow_recoding, $charset, $convcharset;
if ($type != FALSE) {
return PMA_convert_display_charset(mysql_fetch_array($result, $type));
$data = mysql_fetch_array($result, $type);
} else {
return PMA_convert_display_charset(mysql_fetch_array($result));
$data = mysql_fetch_array($result);
}
if (!(isset($cfg['AllowAnywhereRecoding']) && $cfg['AllowAnywhereRecoding'] && $allow_recoding)) {
/* No recoding -> return data as we got them */
return $data;
} else {
$ret = array();
$num = mysql_num_fields($result);
$i = 0;
for($i = 0; $i < $num; $i++) {
$meta = mysql_fetch_field($result);
$name = mysql_field_name($result, $i);
if (!$meta) {
/* No meta information available -> we guess that it should be converted */
if (isset($data[$i])) $ret[$i] = PMA_convert_display_charset($data[$i]);
if (isset($data[$name])) $ret[PMA_convert_display_charset($name)] = PMA_convert_display_charset($data[$name]);
} else {
/* Meta information available -> check type of field and convert it according to the type */
if ($meta->blob || eregi('BINARY', $meta->type)) {
if (isset($data[$i])) $ret[$i] = $data[$i];
if (isset($data[$name])) $ret[PMA_convert_display_charset($name)] = $data[$name];
} else {
if (isset($data[$i])) $ret[$i] = PMA_convert_display_charset($data[$i]);
if (isset($data[$name])) $ret[PMA_convert_display_charset($name)] = PMA_convert_display_charset($data[$name]);
}
}
}
return $ret;
}
}
@@ -45,12 +74,11 @@ if (!defined('PMA_MYSQL_WRAPPERS_LIB_INCLUDED')){
}
}
function PMA_mysql_fetch_object($result) {
return PMA_convert_display_charset(mysql_fetch_object($result));
}
function PMA_mysql_fetch_row($result) {
return PMA_convert_display_charset(mysql_fetch_row($result));
/* nijel: This is not optimal, but keeps us from duplicating code, if
* speed really matters, duplicate here code from PMA_mysql_fetch_array
* with removing rows working with associative array. */
return PMA_mysql_fetch_array($result, MYSQL_NUM);
}
function PMA_mysql_field_flags($result, $field_offset) {