From e015449e2238202b0df36f46999cd603f8b1d22b Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Tue, 3 Sep 2002 16:49:10 +0000 Subject: [PATCH] drop-down for foreign keys --- ChangeLog | 4 ++++ tbl_change.php3 | 43 +++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9b2da390f..170ff28eb 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,10 @@ phpMyAdmin - Changelog $Id$ $Source$ +2002-09-03 Marc Delisle + * tbl_change.php3: drop-down for foreign keys, patch 603939, + thanks to markus at noga.de + 2002-09-03 Loïc Chapeaux * libraries/display_tbl.lib.php3: - fix a PHP3 problem (foreach function was called); diff --git a/tbl_change.php3 b/tbl_change.php3 index 545db1ac3..35d0fa1dc 100755 --- a/tbl_change.php3 +++ b/tbl_change.php3 @@ -8,7 +8,7 @@ require('./libraries/grab_globals.lib.php3'); $js_to_run = 'tbl_change.js'; require('./header.inc.php3'); - +require('./libraries/relation.lib.php3'); // foreign keys /** * Displays the query submitted and its result @@ -135,7 +135,10 @@ else unset($row); } - +// +// retrieve keys into foreign fields, if any +$cfgRelation = PMA_getRelationsParam(); +$foreigners = PMA_getForeigners($db,$table); /** * Displays the form @@ -362,6 +365,42 @@ for ($i = 0; $i < $fields_cnt; $i++) { // The value column (depends on type) // ---------------- + + // + // selection box for foreign keys + + // lem9: array_key_exists() only in PHP >= 4.1.0 + // if(array_key_exists($field,$foreigners)) { + + if (isset($foreigners[$field])) { + $foreigner =$foreigners[$field]; + $foreign_db =$foreigner['foreign_db']; + $foreign_table =$foreigner['foreign_table']; + $foreign_field =$foreigner['foreign_field']; + $foreign_display=PMA_getDisplayField($foreign_db,$foreign_table); + + // FIXME: not using foreign_db + $dispsql= "SELECT $foreign_field,$foreign_display FROM $foreign_table"; + + // lem9: put a LIMIT in case of big foreign table (looking for better + // solution, maybe a configurable limit, or a message?) + $dispsql .= " LIMIT 100"; + $disp = PMA_mysql_query($dispsql); + echo '' . "\n"; + echo ' ' . "\n"; + echo '' . "\n"; + } else + if (strstr($row_table_def['True_Type'], 'text')) { ?>