Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
983c39c3af
1049
db_qbe.php
1049
db_qbe.php
File diff suppressed because it is too large
Load Diff
1278
libraries/DBQbe.class.php
Normal file
1278
libraries/DBQbe.class.php
Normal file
File diff suppressed because it is too large
Load Diff
@ -1161,54 +1161,66 @@ 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 array $all_tables All the involved tables
|
||||
* @param string $master The master table to form the LEFT JOIN clause
|
||||
*
|
||||
* @return string LEFT JOIN
|
||||
* @access private
|
||||
*/
|
||||
function PMA_getRelatives($from)
|
||||
function PMA_getRelatives($all_tables, $master)
|
||||
{
|
||||
global $tab_left, $tab_know, $fromclause;
|
||||
|
||||
$fromclause = '';
|
||||
$emerg = '';
|
||||
$common_functions = PMA_CommonFunctions::getInstance();
|
||||
|
||||
if ($from == 'master') {
|
||||
$to = 'foreign';
|
||||
} else {
|
||||
$to = 'master';
|
||||
}
|
||||
$in_know = '(\'' . implode('\', \'', $tab_know) . '\')';
|
||||
$in_left = '(\'' . implode('\', \'', $tab_left) . '\')';
|
||||
|
||||
$rel_query = 'SELECT *'
|
||||
. ' FROM ' . $common_functions->backquote($GLOBALS['cfgRelation']['db'])
|
||||
. '.' . $common_functions->backquote($GLOBALS['cfgRelation']['relation'])
|
||||
. ' WHERE ' . $from . '_db = \'' . $common_functions->sqlAddSlashes($GLOBALS['db']) . '\''
|
||||
. ' AND ' . $to . '_db = \'' . $common_functions->sqlAddSlashes($GLOBALS['db']) . '\''
|
||||
. ' AND ' . $from . '_table IN ' . $in_know
|
||||
. ' AND ' . $to . '_table IN ' . $in_left;
|
||||
$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])) {
|
||||
$fromclause
|
||||
.= "\n" . ' LEFT JOIN '
|
||||
. $common_functions->backquote($GLOBALS['db']) . '.' . $common_functions->backquote($row[$to . '_table']) . ' ON '
|
||||
. $common_functions->backquote($row[$from . '_table']) . '.'
|
||||
. $common_functions->backquote($row[$from . '_field']) . ' = '
|
||||
. $common_functions->backquote($row[$to . '_table']) . '.'
|
||||
. $common_functions->backquote($row[$to . '_field']) . ' ';
|
||||
$tab_know[$found_table] = $found_table;
|
||||
unset($tab_left[$found_table]);
|
||||
// The list of tables that we still couldn't connect
|
||||
$remaining_tables = $all_tables;
|
||||
unset($remaining_tables[$master]);
|
||||
// The list of allready connected tables
|
||||
$known_tables[$master] = $master;
|
||||
$run = 0;
|
||||
while (count($remaining_tables) > 0) {
|
||||
// Whether to go from master to foreign or vice versa
|
||||
if ($run % 2 == 0) {
|
||||
$from = 'master';
|
||||
$to = 'foreign';
|
||||
} else {
|
||||
$from = 'foreign';
|
||||
$to = 'master';
|
||||
}
|
||||
$in_know = '(\'' . implode('\', \'', $known_tables) . '\')';
|
||||
$in_left = '(\'' . implode('\', \'', $remaining_tables) . '\')';
|
||||
$rel_query = 'SELECT *'
|
||||
. ' FROM ' . $common_functions->backquote($GLOBALS['cfgRelation']['db'])
|
||||
. '.' . $common_functions->backquote($GLOBALS['cfgRelation']['relation'])
|
||||
. ' WHERE ' . $from . '_db = \'' . $common_functions->sqlAddSlashes($GLOBALS['db']) . '\''
|
||||
. ' AND ' . $to . '_db = \'' . $common_functions->sqlAddSlashes($GLOBALS['db']) . '\''
|
||||
. ' AND ' . $from . '_table IN ' . $in_know
|
||||
. ' AND ' . $to . '_table IN ' . $in_left;
|
||||
$relations = @PMA_DBI_query($rel_query, $GLOBALS['controllink']);
|
||||
while ($row = PMA_DBI_fetch_assoc($relations)) {
|
||||
$found_table = $row[$to . '_table'];
|
||||
if (isset($remaining_tables[$found_table])) {
|
||||
$fromclause
|
||||
.= "\n" . ' LEFT JOIN '
|
||||
. $common_functions->backquote($GLOBALS['db']) . '.' . $common_functions->backquote($row[$to . '_table']) . ' ON '
|
||||
. $common_functions->backquote($row[$from . '_table']) . '.'
|
||||
. $common_functions->backquote($row[$from . '_field']) . ' = '
|
||||
. $common_functions->backquote($row[$to . '_table']) . '.'
|
||||
. $common_functions->backquote($row[$to . '_field']) . ' ';
|
||||
$known_tables[$found_table] = $found_table;
|
||||
unset($remaining_tables[$found_table]);
|
||||
}
|
||||
} // end while
|
||||
$run++;
|
||||
if ($run > 5) {
|
||||
foreach ($remaining_tables as $table) {
|
||||
$emerg .= ', ' . $common_functions->backquote($table);
|
||||
unset($remaining_tables[$table]);
|
||||
}
|
||||
}
|
||||
} // end while
|
||||
|
||||
return true;
|
||||
$fromclause = $emerg . $fromclause;
|
||||
return $fromclause;
|
||||
} // end of the "PMA_getRelatives()" function
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user