From bf1d64f119fe95a1a57bd315071613117894d46d Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Wed, 22 May 2002 12:17:54 +0000 Subject: [PATCH] PMA_table_info --- Documentation.html | 24 ++++++++++++++---------- libraries/display_tbl.lib.php3 | 18 ++++++++++++++++-- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/Documentation.html b/Documentation.html index 97aa18347..b33dcfb6e 100755 --- a/Documentation.html +++ b/Documentation.html @@ -596,7 +596,7 @@ $cfg['PmaAbsoluteUri'] = (!empty($HTTPS) ? 'https' : 'http') . '://'
  • display in an optional tooltip the "display field" when browsing the master table, if you move the mouse to a column - containing a foreign key; + containing a foreign key (use also the 'table_info' table);
  • display links on the table properties page, to check referential @@ -626,7 +626,6 @@ $cfg['PmaAbsoluteUri'] = (!empty($HTTPS) ? 'https' : 'http') . '://'        `master_field` varchar(64) NOT NULL default '',
           `foreign_table` varchar(64) NOT NULL default '',
           `foreign_field` varchar(64) NOT NULL default '',
    -        `foreign_display_field` varchar(64) NOT NULL default '',
           `pdf_page_number` int(11) NOT NULL default '0',
           PRIMARY KEY (`master_table`,`master_field`),
           KEY pdf_page_number (`pdf_page_number`)
    @@ -649,7 +648,6 @@ $cfg['PmaAbsoluteUri'] = (!empty($HTTPS) ? 'https' : 'http') . '://'      ALTER TABLE `PMA_relation` CHANGE src_column master_field VARCHAR(64) NOT NULL
         ALTER TABLE `PMA_relation` CHANGE dest_table foreign_table VARCHAR(64) NOT NULL
         ALTER TABLE `PMA_relation` CHANGE dest_column foreign_field VARCHAR(64) NOT NULL
    -      ALTER TABLE `PMA_relation` ADD `foreign_display_field` VARCHAR(64) NOT NULL;
         ALTER TABLE `PMA_relation` ADD `pdf_page_number` int(11) NOT NULL;
         ALTER TABLE `PMA_relation` ADD INDEX(`pdf_page_number`);

    @@ -660,11 +658,17 @@ $cfg['PmaAbsoluteUri'] = (!empty($HTTPS) ? 'https' : 'http') . '://'
    Since release 2.3.0 you can describe, in a special 'table_info' - table, the coordinates where each table will be placed on a PDF schema - output. This configuration variable will hold the name of this special + table +
      +
    • the coordinates where each table will be placed on a PDF schema + output
    • +
    • which field is to be displayed as a tooltip when moving the + cursor over the corresponding key
    • +
    + This configuration variable will hold the name of this special table.

    - This feature is supported under PHP4, and you must be using also the + PDF output is supported under PHP4, and you must be using also the 'relation' feature. Also, we used the fpdf library which currently only supports iso-8859 (Latin1) character sets in PDF.

    @@ -678,6 +682,7 @@ $cfg['PmaAbsoluteUri'] = (!empty($HTTPS) ? 'https' : 'http') . '://'        `table_name` varchar(64) NOT NULL default '',
           `x` float unsigned NOT NULL default '0',
           `y` float unsigned NOT NULL default '0',
    +        `display_field` varchar(64) NOT NULL default '',
           PRIMARY KEY (`table_name`)
         ) TYPE=MyISAM COMMENT='Table information for phpMyAdmin';
    @@ -688,7 +693,7 @@ $cfg['PmaAbsoluteUri'] = (!empty($HTTPS) ? 'https' : 'http') . '://'
  • then manually fill this table with information about the table - positions on the PDF schema. + positions on the PDF schema, and/or the display field.

  • See also this usage tip. @@ -1732,14 +1737,13 @@ $cfg['PmaAbsoluteUri'] = (!empty($HTTPS) ? 'https' : 'http') . '://'        master_field varchar(64) NOT NULL default '',
           foreign_table varchar(64) NOT NULL default '',
           foreign_field varchar(64) NOT NULL default '',
    -        foreign_display_field varchar(64) NOT NULL default '',
           pdf_page_number int(11) NOT NULL default '0',
           PRIMARY KEY (master_table,master_field),
           KEY pdf_page_number (`pdf_page_number`)
         ) TYPE=MyISAM;

    -      INSERT INTO `PMA_relation` VALUES ('persons', 'town_code', 'towns', 'town_code','description', 1);
    -      INSERT INTO `PMA_relation` VALUES ('persons', 'country_code', 'countries', 'country_code','description', 1);
    +      INSERT INTO `PMA_relation` VALUES ('persons', 'town_code', 'towns', 'town_code', 1);
    +      INSERT INTO `PMA_relation` VALUES ('persons', 'country_code', 'countries', 'country_code', 1);

         CREATE TABLE towns (
           town_code varchar(5) NOT NULL default '0',
    diff --git a/libraries/display_tbl.lib.php3 b/libraries/display_tbl.lib.php3 index a8273f28b..a40dd62ec 100644 --- a/libraries/display_tbl.lib.php3 +++ b/libraries/display_tbl.lib.php3 @@ -1359,13 +1359,27 @@ if (!defined('PMA_DISPLAY_TBL_LIB_INCLUDED')){ $target = eregi_replace('^.*[[:space:]]+FROM[[:space:]]+`?|`?[[:space:]]*(ON[[:space:]]+[^,]+)?(WHERE[[:space:]]+.*)?$', '', $sql_query); $tabs = '(\'' . join('\',\'', split($pattern, $target)) . '\')'; - $local_query = 'SELECT master_field, foreign_table, foreign_field, foreign_display_field' + $local_query = 'SELECT master_field, foreign_table, foreign_field' . ' FROM ' . PMA_backquote($cfg['Server']['relation']) . ' WHERE master_table IN ' . $tabs; $result = @mysql_query($local_query); if ($result) { while ($rel = mysql_fetch_row($result)) { - $map[$rel[0]] = array($rel[1], $rel[2], $rel[3]); + + // check for display field? + if (!empty($cfg['Server']['table_info'])) { + $ti_query = 'SELECT display_field' + . ' FROM ' . $cfg['Server']['table_info'] + . ' WHERE table_name = \'' . $rel[1] . '\''; + $result_ti = @mysql_query($ti_query); + if ($result_ti) { + list($display_field) = mysql_fetch_row($result_ti); + } + else { + $display_field = ''; + } + } + $map[$rel[0]] = array($rel[1], $rel[2], $display_field); } } } // end 2b