Remove some global variables
This commit is contained in:
parent
aea70f5743
commit
1623e5581d
@ -255,7 +255,7 @@ if (isset($criteriaColumn) && count($criteriaColumn) > 0) {
|
||||
$all_columns = array();
|
||||
$tab_know = array();
|
||||
$left_tables = array();
|
||||
$fromclause = '';
|
||||
$left_join = '';
|
||||
|
||||
// We only start this if we have fields, otherwise it would be dumb
|
||||
foreach ($criteriaColumn as $value) {
|
||||
@ -287,20 +287,19 @@ if (isset($criteriaColumn) && count($criteriaColumn) > 0) {
|
||||
$emerg = '';
|
||||
while (count($left_tables) > 0) {
|
||||
if ($run % 2 == 0) {
|
||||
PMA_getRelatives('master');
|
||||
$left_join .= PMA_getRelatives('master', $left_tables, $tab_know);
|
||||
} else {
|
||||
PMA_getRelatives('foreign');
|
||||
$left_join .= PMA_getRelatives('foreign', $left_tables, $tab_know);
|
||||
}
|
||||
$run++;
|
||||
if ($run > 5) {
|
||||
|
||||
foreach ($left_tables as $table) {
|
||||
$emerg .= ', ' . $common_functions->backquote($table);
|
||||
unset($left_tables[$table]);
|
||||
}
|
||||
}
|
||||
} // end while
|
||||
$qry_from = $common_functions->backquote($master) . $emerg . $fromclause;
|
||||
$qry_from = $common_functions->backquote($master) . $emerg . $left_join;
|
||||
} // end if ($cfgRelation['relwork'] && count($all_tables) > 0)
|
||||
|
||||
} // end count($criteriaColumn) > 0
|
||||
|
||||
@ -1161,20 +1161,16 @@ function PMA_getForeignData($foreigners, $field, $override_total, $foreign_filte
|
||||
/**
|
||||
* Finds all related tables
|
||||
*
|
||||
* @param string $from whether to go from master to foreign or vice versa
|
||||
*
|
||||
* @return boolean always true
|
||||
*
|
||||
* @global array $tab_left the list of tables that we still couldn't connect
|
||||
* @global array $tab_know the list of allready connected tables
|
||||
* @global string $fromclause
|
||||
* @param string $from Whether to go from master to foreign or vice versa
|
||||
* @param array $left_tables The list of tables that we still couldn't connect
|
||||
* @param array $tab_know The list of allready connected tables
|
||||
*
|
||||
* @return string LEFT JOIN
|
||||
* @access private
|
||||
*/
|
||||
function PMA_getRelatives($from)
|
||||
function PMA_getRelatives($from, $left_tables, $tab_know)
|
||||
{
|
||||
global $tab_left, $tab_know, $fromclause;
|
||||
|
||||
$fromclause = '';
|
||||
$common_functions = PMA_CommonFunctions::getInstance();
|
||||
|
||||
if ($from == 'master') {
|
||||
@ -1183,7 +1179,7 @@ function PMA_getRelatives($from)
|
||||
$to = 'master';
|
||||
}
|
||||
$in_know = '(\'' . implode('\', \'', $tab_know) . '\')';
|
||||
$in_left = '(\'' . implode('\', \'', $tab_left) . '\')';
|
||||
$in_left = '(\'' . implode('\', \'', $left_tables) . '\')';
|
||||
|
||||
$rel_query = 'SELECT *'
|
||||
. ' FROM ' . $common_functions->backquote($GLOBALS['cfgRelation']['db'])
|
||||
@ -1195,7 +1191,7 @@ function PMA_getRelatives($from)
|
||||
$relations = @PMA_DBI_query($rel_query, $GLOBALS['controllink']);
|
||||
while ($row = PMA_DBI_fetch_assoc($relations)) {
|
||||
$found_table = $row[$to . '_table'];
|
||||
if (isset($tab_left[$found_table])) {
|
||||
if (isset($left_tables[$found_table])) {
|
||||
$fromclause
|
||||
.= "\n" . ' LEFT JOIN '
|
||||
. $common_functions->backquote($GLOBALS['db']) . '.' . $common_functions->backquote($row[$to . '_table']) . ' ON '
|
||||
@ -1204,11 +1200,11 @@ function PMA_getRelatives($from)
|
||||
. $common_functions->backquote($row[$to . '_table']) . '.'
|
||||
. $common_functions->backquote($row[$to . '_field']) . ' ';
|
||||
$tab_know[$found_table] = $found_table;
|
||||
unset($tab_left[$found_table]);
|
||||
unset($left_tables[$found_table]);
|
||||
}
|
||||
} // end while
|
||||
|
||||
return true;
|
||||
return $fromclause;
|
||||
} // end of the "PMA_getRelatives()" function
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user