Documentation TYPO3 par Ameos

get_foreign.lib.php

00001 <?php
00002 /* $Id: get_foreign.lib.php,v 2.6 2005/06/23 14:16:33 robbat2 Exp $ */
00003 // vim: expandtab sw=4 ts=4 sts=4:
00004 
00005 
00012 // lem9: we always show the foreign field in the drop-down; if a display
00013 // field is defined, we show it besides the foreign field
00014 $foreign_link = false;
00015 if ($foreigners && isset($foreigners[$field])) {
00016     $foreigner       = $foreigners[$field];
00017     $foreign_db      = $foreigner['foreign_db'];
00018     $foreign_table   = $foreigner['foreign_table'];
00019     $foreign_field   = $foreigner['foreign_field'];
00020 
00021     // Count number of rows in the foreign table. Currently we do
00022     // not use a drop-down if more than 200 rows in the foreign table,
00023     // for speed reasons and because we need a better interface for this.
00024     //
00025     // We could also do the SELECT anyway, with a LIMIT, and ensure that
00026     // the current value of the field is one of the choices.
00027 
00028     $the_total   = PMA_countRecords($foreign_db, $foreign_table, TRUE);
00029 
00030     if ((isset($override_total) && $override_total == true) || $the_total < $cfg['ForeignKeyMaxLimit']) {
00031         // foreign_display can be FALSE if no display field defined:
00032 
00033         $foreign_display = PMA_getDisplayField($foreign_db, $foreign_table);
00034         $dispsql         = 'SELECT ' . PMA_backquote($foreign_field)
00035                          . (($foreign_display == FALSE) ? '' : ', ' . PMA_backquote($foreign_display))
00036                          . ' FROM ' . PMA_backquote($foreign_db) . '.' . PMA_backquote($foreign_table)
00037                          . (($foreign_display == FALSE) ? '' :' ORDER BY ' . PMA_backquote($foreign_table) . '.' . PMA_backquote($foreign_display))
00038                          . (isset($foreign_limit) ? $foreign_limit : '');
00039         $disp            = PMA_DBI_query($dispsql);
00040         if ($disp) {
00041             // garvin: If a resultset has been created, pre-cache it in the $disp_row array
00042             // This helps us from not needing to use mysql_data_seek by accessing a pre-cached
00043             // PHP array. Usually those resultsets are not that big, so a performance hit should
00044             // not be expected.
00045             $disp_row = array();
00046             while ($single_disp_row = @PMA_DBI_fetch_assoc($disp)) {
00047                 $disp_row[] = $single_disp_row;
00048             }
00049             @PMA_DBI_free_result($disp);
00050         }
00051     }
00052     else {
00053         unset($disp_row);
00054         $foreign_link = true;
00055     }
00056 }  // end if $foreigners
00057 
00058 ?>


Généré par Les spécialistes TYPO3 avec  doxygen 1.4.6