Fix paging.

This commit is contained in:
Michal Čihař
2005-10-12 09:01:04 +00:00
parent 96d1b5cc8b
commit 07adb8da8e
2 changed files with 22 additions and 11 deletions

View File

@@ -5,6 +5,9 @@ phpMyAdmin - Changelog
$Id$
$Source$
2005-10-12 Michal Čihař <michal@cihar.com>
* libraries/get_foreign.lib.php: Fix paging.
2005-10-11 Marc Delisle <lem9@users.sourceforge.net>
* libraries/grab_globals.lib.php: bug #1322871, local file inclusion

View File

@@ -29,20 +29,29 @@ if ($foreigners && isset($foreigners[$field])) {
if ((isset($override_total) && $override_total == true) || $the_total < $cfg['ForeignKeyMaxLimit']) {
// 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)
. (empty($foreign_filter) ? '' : ' WHERE ' . PMA_backquote($foreign_field)
$f_query_main = 'SELECT ' . PMA_backquote($foreign_field)
. (($foreign_display == FALSE) ? '' : ', ' . PMA_backquote($foreign_display));
$f_query_from = ' FROM ' . PMA_backquote($foreign_db) . '.' . PMA_backquote($foreign_table);
$f_query_filter = 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))
. (isset($foreign_limit) ? $foreign_limit : '');
$disp = PMA_DBI_query($dispsql);
);
$f_query_order = ($foreign_display == FALSE) ? '' :' ORDER BY ' . PMA_backquote($foreign_table) . '.' . PMA_backquote($foreign_display);
$f_query_limit = isset($foreign_limit) ? $foreign_limit : '';
if (!empty($foreign_filter)) {
$res = PMA_DBI_query('SELECT COUNT(*)' . $f_query_from . $f_query_filter);
if ($res) {
$the_total = PMA_DBI_fetch_value($res);
} else {
$the_total = 0;
}
}
$disp = PMA_DBI_query($f_query_main . $f_query_from . $f_query_filter . $f_query_order . $f_query_limit);
if ($disp) {
// garvin: If a resultset has been created, pre-cache it in the $disp_row array
// This helps us from not needing to use mysql_data_seek by accessing a pre-cached
@@ -52,7 +61,6 @@ if ($foreigners && isset($foreigners[$field])) {
while ($single_disp_row = @PMA_DBI_fetch_assoc($disp)) {
$disp_row[] = $single_disp_row;
}
$the_total = count($disp_row);
@PMA_DBI_free_result($disp);
}
}