From 5b081dabb85f67d30da7dc535b177e408c167bc7 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Mon, 8 Aug 2005 14:57:05 +0000 Subject: [PATCH] bug #1253453, using mysqli extension with MySQL 4.0.x --- ChangeLog | 4 ++++ libraries/dbi/mysqli.dbi.lib.php | 36 +++++++++++++++++++++++++------- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 07a9dc32e..bdcd1bbb2 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,10 @@ phpMyAdmin - Changelog $Id$ $Source$ +2005-08-08 Marc Delisle + * libraries/dbi/mysqli.dbi.lib.php: bug #1253453, using mysqli extension + with MySQL 4.0.x + 2005-08-07 Marc Delisle * Documentation.html: Save button for PDF schema coordinates, thanks to Ryan Schmidt diff --git a/libraries/dbi/mysqli.dbi.lib.php b/libraries/dbi/mysqli.dbi.lib.php index 68d55c468..3e426367c 100644 --- a/libraries/dbi/mysqli.dbi.lib.php +++ b/libraries/dbi/mysqli.dbi.lib.php @@ -141,21 +141,35 @@ function PMA_mysqli_fetch_array($result, $type = FALSE) { } else { $ret = array(); $num = mysqli_num_fields($result); - $fields = mysqli_fetch_fields($result); + if ($num > 0) { + $fields = PMA_DBI_get_fields_meta($result); + } $i = 0; for ($i = 0; $i < $num; $i++) { - if (!$meta) { + if (!isset($fields[$i]->type)) { /* 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]); + if (isset($data[$i])) { + $ret[$i] = PMA_convert_display_charset($data[$i]); + } + if (isset($fields[$i]->name) && isset($data[$fields[$i]->name])) { + $ret[PMA_convert_display_charset($fields[$i]->name)] = PMA_convert_display_charset($data[$fields[$i]->name]); + } } else { /* Meta information available -> check type of field and convert it according to the type */ if (stristr($fields[$i]->type, 'BLOB') || stristr($fields[$i]->type, 'BINARY')) { - if (isset($data[$i])) $ret[$i] = $data[$i]; - if (isset($data[$fields[$i]->name])) $ret[PMA_convert_display_charset($fields[$i]->name)] = $data[$fields[$i]->name]; + if (isset($data[$i])) { + $ret[$i] = $data[$i]; + } + if (isset($data[$fields[$i]->name])) { + $ret[PMA_convert_display_charset($fields[$i]->name)] = $data[$fields[$i]->name]; + } } else { - if (isset($data[$i])) $ret[$i] = PMA_convert_display_charset($data[$i]); - if (isset($data[$fields[$i]->name])) $ret[PMA_convert_display_charset($fields[$i]->name)] = PMA_convert_display_charset($data[$fields[$i]->name]); + if (isset($data[$i])) { + $ret[$i] = PMA_convert_display_charset($data[$i]); + } + if (isset($data[$fields[$i]->name])) { + $ret[PMA_convert_display_charset($fields[$i]->name)] = PMA_convert_display_charset($data[$fields[$i]->name]); + } } } } @@ -293,6 +307,12 @@ function PMA_DBI_get_fields_meta($result) { $typeAr[MYSQLI_TYPE_GEOMETRY] = 'unknown'; $fields = mysqli_fetch_fields($result); + + // this happens sometimes (seen under MySQL 4.0.25) + if (!is_array($fields)) { + return FALSE; + } + foreach ($fields as $k => $field) { $fields[$k]->type = $typeAr[$fields[$k]->type]; $fields[$k]->flags = PMA_DBI_field_flags($result, $k);