diff --git a/ChangeLog b/ChangeLog index 65ae21c78..d8866b15a 100755 --- a/ChangeLog +++ b/ChangeLog @@ -7,7 +7,10 @@ $Source$ 2004-08-11 Michal Čihař * tbl_replace.php: Do not empty protected values (bug #1006812). - * libraries/display_tbl.lib.php: Wrong parameters for PMA_DBI_free_result (bug #1007287). + * libraries/display_tbl.lib.php: Wrong parameters for PMA_DBI_free_result + (bug #1007287). + * tbl_indexes.php, libraries/display_tbl.lib.php: Fix grabing indexes with + MYSQLI_USE_RESULT (bug #1007286). 2004-08-10 Michal Čihař * libraries/tbl_change.js: Forcibily use 10 as base for parsed numbers, diff --git a/libraries/display_tbl.lib.php b/libraries/display_tbl.lib.php index 7ad20f6af..408a6360c 100644 --- a/libraries/display_tbl.lib.php +++ b/libraries/display_tbl.lib.php @@ -489,12 +489,18 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $ $sort_expression_nodir = isset($matches[1]) ? trim($matches[1]) : $sort_expression; // grab indexes data: - $result = PMA_DBI_query('SHOW KEYS FROM ' . PMA_backquote($table) . ';'); - $idx_cnt = PMA_DBI_num_rows($result); + if (!defined('PMA_IDX_INCLUDED')) { + $local_query = 'SHOW KEYS FROM ' . PMA_backquote($table); + $result = PMA_DBI_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0); + $ret_keys = array(); + while ($row = PMA_DBI_fetch_assoc($result)) { + $ret_keys[] = $row; + } + PMA_DBI_free_result($result); + } $prev_index = ''; - for ($i = 0; $i < $idx_cnt; $i++) { - $row = (defined('PMA_IDX_INCLUDED') ? $ret_keys[$i] : PMA_DBI_fetch_assoc($result)); + foreach ($ret_keys as $row) { if ($row['Key_name'] != $prev_index ){ $indexes[] = $row['Key_name']; diff --git a/tbl_indexes.php b/tbl_indexes.php index 96e05c1f6..00c4687d2 100644 --- a/tbl_indexes.php +++ b/tbl_indexes.php @@ -66,17 +66,17 @@ $prev_index = ''; $indexes_info = array(); $indexes_data = array(); // keys had already been grabbed in "tbl_properties.php" -if (defined('PMA_IDX_INCLUDED')) { - $idx_cnt = count($ret_keys); -} else { +if (!defined('PMA_IDX_INCLUDED')) { $local_query = 'SHOW KEYS FROM ' . PMA_backquote($table); $result = PMA_DBI_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0); - $idx_cnt = PMA_DBI_num_rows($result); + $ret_keys = array(); + while ($row = PMA_DBI_fetch_assoc($result)) { + $ret_keys[] = $row; + } + PMA_DBI_free_result($result); } -for ($i = 0; $i < $idx_cnt; $i++) { - $row = (defined('PMA_IDX_INCLUDED') ? $ret_keys[$i] : PMA_DBI_fetch_assoc($result)); - +foreach ($ret_keys as $row) { if ($row['Key_name'] != $prev_index ){ $indexes[] = $row['Key_name']; $prev_index = $row['Key_name']; @@ -101,12 +101,6 @@ for ($i = 0; $i < $idx_cnt; $i++) { } } // end while -if (defined('PMA_IDX_INCLUDED')) { - unset($ret_keys); -} else if ($result) { - PMA_DBI_free_result($result); -} - // Get fields and stores their name/type // fields had already been grabbed in "tbl_properties.php" if (!defined('PMA_IDX_INCLUDED')) { @@ -427,7 +421,7 @@ else if (!defined('PMA_IDX_INCLUDED') $drop_link_text = '' . $drop_link_text . ''; } - if ($idx_cnt > 0) { + if (count($ret_keys) > 0) { ?>