Support for searching in foreign keys (RFE #871091).

This commit is contained in:
Michal Čihař
2005-10-09 12:49:22 +00:00
parent c7dc601156
commit f25a50a9be
3 changed files with 15 additions and 0 deletions

View File

@@ -24,6 +24,8 @@ $Source$
#1191792). #1191792).
* tbl_properties.inc.php: Remove unused code, show only available engines, * tbl_properties.inc.php: Remove unused code, show only available engines,
remember value of seleted engine (bug #1239580). remember value of seleted engine (bug #1239580).
* browse_foreigners.php, libraries/get_foreign.lib.php: Support for
searching in foreign keys (RFE #871091).
2005-10-08 Marc Delisle <lem9@users.sourceforge.net> 2005-10-08 Marc Delisle <lem9@users.sourceforge.net>
* libraries/session.inc.php: workaround for warnings on session_start() * libraries/session.inc.php: workaround for warnings on session_start()

View File

@@ -99,6 +99,11 @@ if (isset($pk)) {
} }
?> ?>
<label for="input_foreign_filter"><?php echo $strSearch . ':'; ?></label>
<input type="text" name="foreign_filter" id="input_foreign_filter" value="<?php echo isset($foreign_filter) ? htmlspecialchars($foreign_filter) : ''; ?>" />
<input type="submit" name="submit_foreign_filter" value="<?php echo $strGo;?>" />
<hr />
<table width="100%"> <table width="100%">
<?php <?php
if ($cfg['ShowAll'] && ($the_total > $per_page)) { if ($cfg['ShowAll'] && ($the_total > $per_page)) {
@@ -117,6 +122,7 @@ if ($the_total > $per_page) {
'&amp;' . PMA_generate_common_url($db, $table) '&amp;' . PMA_generate_common_url($db, $table)
. $pk_uri . . $pk_uri .
'&amp;fieldkey=' . (isset($fieldkey) ? $fieldkey : '') . '&amp;fieldkey=' . (isset($fieldkey) ? $fieldkey : '') .
'&amp;foreign_filter=' . (isset($foreign_filter) ? htmlspecialchars($foreign_filter) : '') .
'&amp;', '&amp;',
$session_max_rows, $session_max_rows,
$pageNow, $pageNow,

View File

@@ -34,6 +34,12 @@ if ($foreigners && isset($foreigners[$field])) {
$dispsql = 'SELECT ' . PMA_backquote($foreign_field) $dispsql = 'SELECT ' . PMA_backquote($foreign_field)
. (($foreign_display == FALSE) ? '' : ', ' . PMA_backquote($foreign_display)) . (($foreign_display == FALSE) ? '' : ', ' . PMA_backquote($foreign_display))
. ' FROM ' . PMA_backquote($foreign_db) . '.' . PMA_backquote($foreign_table) . ' FROM ' . PMA_backquote($foreign_db) . '.' . PMA_backquote($foreign_table)
. (empty($foreign_filter) ? '' : ' WHERE ' . PMA_backquote($foreign_field)
. ' LIKE "%' . PMA_sqlAddslashes($foreign_filter, TRUE) . '%"'
. (($foreign_display == FALSE) ? '' : ' OR ' . PMA_backquote($foreign_display)
. ' LIKE "%' . PMA_sqlAddslashes($foreign_filter, TRUE) . '%"'
)
)
. (($foreign_display == FALSE) ? '' :' ORDER BY ' . PMA_backquote($foreign_table) . '.' . PMA_backquote($foreign_display)) . (($foreign_display == FALSE) ? '' :' ORDER BY ' . PMA_backquote($foreign_table) . '.' . PMA_backquote($foreign_display))
. (isset($foreign_limit) ? $foreign_limit : ''); . (isset($foreign_limit) ? $foreign_limit : '');
$disp = PMA_DBI_query($dispsql); $disp = PMA_DBI_query($dispsql);
@@ -46,6 +52,7 @@ if ($foreigners && isset($foreigners[$field])) {
while ($single_disp_row = @PMA_DBI_fetch_assoc($disp)) { while ($single_disp_row = @PMA_DBI_fetch_assoc($disp)) {
$disp_row[] = $single_disp_row; $disp_row[] = $single_disp_row;
} }
$the_total = count($disp_row);
@PMA_DBI_free_result($disp); @PMA_DBI_free_result($disp);
} }
} }