From 9c0b758a6e652d0a4ac05d06b9bce19a084487d1 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Thu, 3 Oct 2002 21:25:21 +0000 Subject: [PATCH] drop-down in Select sub-page --- ChangeLog | 5 +++++ tbl_change.php3 | 34 +--------------------------------- tbl_select.php3 | 39 ++++++++++++++++++++++++++++++++++++--- 3 files changed, 42 insertions(+), 36 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3dde51877..5d6ba7817 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,11 @@ phpMyAdmin - Changelog $Id$ $Source$ +2002-10-03 Marc Delisle + * tbl_select.php3, tbl_change.php3, + new libraries/get_foreign.lib.php3: drop-down of foreign keys + on Select sub-page, thanks to Markus L. Noga (mlnoga) + 2002-10-03 Alexander M. Turek * tbl_dump.php3, libraries/build_dump.lib.php3: Completed fix against bug #607896, thanks to Loïc. diff --git a/tbl_change.php3 b/tbl_change.php3 index 812c46a27..1b1226e72 100755 --- a/tbl_change.php3 +++ b/tbl_change.php3 @@ -392,39 +392,7 @@ for ($i = 0; $i < $fields_cnt; $i++) { // The value column (depends on type) // ---------------- - // - // selection box for foreign keys - - // lem9: we always show the foreign field in the drop-down; if a display - // field is defined, we show it besides the foreign field - if ($foreigners && isset($foreigners[$field])) { - $foreigner = $foreigners[$field]; - $foreign_db = $foreigner['foreign_db']; - $foreign_table = $foreigner['foreign_table']; - $foreign_field = $foreigner['foreign_field']; - - // Count number of rows in the foreign table. Currently we do - // not use a drop-down if more than 200 rows in the foreign table, - // for speed reasons and because we need a better interface for this. - // - // We could also do the SELECT anyway, with a LIMIT, and ensure that - // the current value of the field is one of the choices. - - $count_query = 'SELECT COUNT(*) AS total FROM ' . PMA_backquote($foreign_db) . '.' . PMA_backquote($foreign_table); - $count_result = PMA_mysql_query($count_query) or PMA_mysqlDie('', $count_query, '', $err_url); - $the_total = PMA_mysql_result($count_result, 0, 'total'); - mysql_free_result($count_result); - - if ($the_total < 200) { - // foreign_display can be FALSE if no display field defined: - $foreign_display = PMA_getDisplayField($foreign_db, $foreign_table); - $dispsql = 'SELECT ' . PMA_backquote($foreign_field) - . (($foreign_display == FALSE) ? '' : ', ' . PMA_backquote($foreign_display)) - . ' FROM ' . PMA_backquote($foreign_db) . '.' . PMA_backquote($foreign_table) - . ' ORDER BY ' . PMA_backquote($foreign_table) . '.' . PMA_backquote($foreign_display); - $disp = PMA_mysql_query($dispsql); - } - } // end if $foreigners + require('./libraries/get_foreign.lib.php3'); if (isset($disp) && $disp) { ?> diff --git a/tbl_select.php3 b/tbl_select.php3 index 381f84d97..df2f87e22 100755 --- a/tbl_select.php3 +++ b/tbl_select.php3 @@ -7,6 +7,7 @@ */ require('./libraries/grab_globals.lib.php3'); require('./libraries/common.lib.php3'); +require('./libraries/relation.lib.php3'); // foreign keys /** @@ -62,6 +63,11 @@ if (!isset($param) || $param[0] == '') { $fields_type[] = $type; } // end while mysql_free_result($result); + + // + // retrieve keys into foreign fields, if any + $cfgRelation = PMA_getRelationsParam(); + $foreigners = ($cfgRelation['relwork'] ? PMA_getForeigners($db, $table) : FALSE); ?>
@@ -132,9 +138,36 @@ if (!isset($param) || $param[0] == '') { - - - + + $field=$fields_list[$i]; + + require('./libraries/get_foreign.lib.php3'); + + if($foreigners && isset($foreigners[$field]) && + isset($disp) && $disp) { + ?> + + + + + +