diff --git a/ChangeLog b/ChangeLog index af5a8f6de..dfb01968c 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,13 @@ phpMyAdmin - Changelog $Id$ $Source$ +2004-01-28 Garvin Hicking + * browser_foreigners, tbl_change.php, tbl_indexes.php, + tbl_properties_structure.php, tbl_relation.php, tbl_select.php, + libraries/get_foreign.lib.php, libraries/relation.lib.php: + Get rid of mysql_data_seek(). Use pre-cached PHP array for + mysqli compatibility and bandwidth saving. + 2004-01-27 Marc Delisle * main.php: bug 884606, MySQL version check before server choice diff --git a/browse_foreigners.php b/browse_foreigners.php index e7e1c0fd7..7d032a37b 100644 --- a/browse_foreigners.php +++ b/browse_foreigners.php @@ -138,7 +138,7 @@ $header = ' echo $header; -if (isset($disp) && $disp) { +if (isset($disp_row) && is_array($disp_row)) { function dimsort($arrayA, $arrayB) { $keyA = key($arrayA); $keyB = key($arrayB); @@ -153,7 +153,7 @@ if (isset($disp) && $disp) { $mysql_key_relrow = array(); $mysql_val_relrow = array(); $count = 0; - while ($relrow = @PMA_DBI_fetch_assoc($disp)) { + foreach($disp_row AS $disp_row_key => $relrow) { if ($foreign_display != FALSE) { $val = $relrow[$foreign_display]; } else { diff --git a/libraries/get_foreign.lib.php b/libraries/get_foreign.lib.php index 35957cf08..5bfb1a820 100644 --- a/libraries/get_foreign.lib.php +++ b/libraries/get_foreign.lib.php @@ -37,6 +37,17 @@ if ($foreigners && isset($foreigners[$field])) { . (($foreign_display == FALSE) ? '' :' ORDER BY ' . PMA_backquote($foreign_table) . '.' . PMA_backquote($foreign_display)) . (isset($foreign_limit) ? $foreign_limit : ''); $disp = PMA_DBI_query($dispsql); + if ($disp) { + // garvin: If a resultset has been created, pre-cache it in the $disp_row array + // This helps us from not needing to use mysql_data_seek by accessing a pre-cached + // PHP array. Usually those resultsets are not that big, so a performance hit should + // not be expected. + $disp_row = array(); + while ($single_disp_row = @PMA_DBI_fetch_assoc($disp)) { + $disp_row[] = $single_disp_row; + } + @PMA_DBI_free_result($disp); + } } else { unset($disp); diff --git a/libraries/relation.lib.php b/libraries/relation.lib.php index f5fa52267..de9162726 100644 --- a/libraries/relation.lib.php +++ b/libraries/relation.lib.php @@ -601,7 +601,8 @@ function PMA_foreignDropdown($disp, $foreign_field, $foreign_display, $data, $ma $ret = '' . "\n"; $reloptions = array('content-id' => array(), 'id-content' => array()); - while ($relrow = @PMA_DBI_fetch_assoc($disp)) { + + foreach($disp AS $disp_key => $relrow) { $key = $relrow[$foreign_field]; if (strlen($relrow[$foreign_display]) <= $cfg['LimitChars']) { $value = (($foreign_display != FALSE) ? htmlspecialchars($relrow[$foreign_display]) : ''); diff --git a/tbl_change.php b/tbl_change.php index 08c99d8ee..3a6e998d7 100644 --- a/tbl_change.php +++ b/tbl_change.php @@ -507,18 +507,18 @@ foreach($loop_array AS $vrowcount => $vrow) { diff --git a/tbl_indexes.php b/tbl_indexes.php index cab4dcf95..1eeaa0490 100644 --- a/tbl_indexes.php +++ b/tbl_indexes.php @@ -109,16 +109,18 @@ if (defined('PMA_IDX_INCLUDED')) { // Get fields and stores their name/type // fields had already been grabbed in "tbl_properties.php" -if (defined('PMA_IDX_INCLUDED')) { - mysql_data_seek($fields_rs, 0); // !UNWRAPPED FUNCTION! -} else { +if (!defined('PMA_IDX_INCLUDED')) { $fields_rs = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ';'); $fields_cnt = PMA_DBI_num_rows($fields_rs); + $save_row = array(); + while ($row = PMA_DBI_fetch_assoc($fields_rs)) { + $save_row[] = $row; + } } $fields_names = array(); $fields_types = array(); -while ($row = PMA_DBI_fetch_assoc($fields_rs)) { +foreach($save_row AS $saved_row_key => $row) { $fields_names[] = $row['Field']; // loic1: set or enum types: slashes single quotes inside options if (preg_match('@^(set|enum)\((.+)\)$@i', $row['Type'], $tmp)) { diff --git a/tbl_properties_structure.php b/tbl_properties_structure.php index 7dff57611..4a8b3cc34 100644 --- a/tbl_properties_structure.php +++ b/tbl_properties_structure.php @@ -112,8 +112,10 @@ if ($GLOBALS['cfg']['ShowPropertyComments']) { $i = 0; $aryFields = array(); $checked = (!empty($checkall) ? ' checked="checked"' : ''); +$save_row = array(); while ($row = PMA_DBI_fetch_assoc($fields_rs)) { + $save_row[] = $row; $i++; $bgcolor = ($i % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; $aryFields[] = $row['Field']; diff --git a/tbl_relation.php b/tbl_relation.php index 84b4b6c22..d39e6a666 100644 --- a/tbl_relation.php +++ b/tbl_relation.php @@ -505,8 +505,7 @@ if ($col_rs && PMA_DBI_num_rows($col_rs) > 0) { ' . "\n"; // go back to first row - mysql_data_seek($disp,0); // !UNWRAPPED FUNCTION! - echo PMA_foreignDropdown($disp, $foreign_field, $foreign_display, $data, 100); + echo PMA_foreignDropdown($disp_row, $foreign_field, $foreign_display, $data, 100); echo ' ' . "\n"; } else if (isset($foreign_link) && $foreign_link == true) { ?>