PMA\libraries\DbQbe::_loadRelationsForTable PHP Method

_loadRelationsForTable() private method

Loads relations for a given table into the $relations array
private _loadRelationsForTable ( &$relations, string $oneTable ) : void
$oneTable string the table
return void
    private function _loadRelationsForTable(&$relations, $oneTable)
    {
        $relations[$oneTable] = array();
        $foreigners = PMA_getForeigners($GLOBALS['db'], $oneTable);
        foreach ($foreigners as $field => $foreigner) {
            // Foreign keys data
            if ($field == 'foreign_keys_data') {
                foreach ($foreigner as $oneKey) {
                    $clauses = array();
                    // There may be multiple column relations
                    foreach ($oneKey['index_list'] as $index => $oneField) {
                        $clauses[] = Util::backquote($oneTable) . "." . Util::backquote($oneField) . " = " . Util::backquote($oneKey['ref_table_name']) . "." . Util::backquote($oneKey['ref_index_list'][$index]);
                    }
                    // Combine multiple column relations with AND
                    $relations[$oneTable][$oneKey['ref_table_name']] = implode(" AND ", $clauses);
                }
            } else {
                // Internal relations
                $relations[$oneTable][$foreigner['foreign_table']] = Util::backquote($oneTable) . "." . Util::backquote($field) . " = " . Util::backquote($foreigner['foreign_table']) . "." . Util::backquote($foreigner['foreign_field']);
            }
        }
    }