$tab_left = PMA_arrayShort($tab_left, $found_table); } } // end while return TRUE; } // end of the "PMA_getRelatives()" function $tab_left = PMA_arrayShort($tab_all, $master); $tab_know[$master] = $master; $run = 0; $emerg = ''; while (count($tab_left) > 0) { if ($run % 2 == 0) { PMA_getRelatives('master'); } else { PMA_getRelatives('foreign'); } $run++; if ($run > 5) { foreach ($tab_left as $tab) { $emerg .= ', ' . PMA_backquote($tab); $tab_left = PMA_arrayShort($tab_left, $tab); } } } // end while $qry_from = PMA_backquote($master) . $emerg . $fromclause; } // end if ($cfgRelation['relwork'] && count($tab_all) > 0) } // end count($Field) > 0
/** * Provides FROM clause for building SQL query * * @return string FROM clause */ private function _getFromClause() { $from_clause = ''; if (isset($_POST['criteriaColumn']) && count($_POST['criteriaColumn']) > 0) { // Initialize some variables $all_tables = $all_columns = array(); // We only start this if we have fields, otherwise it would be dumb foreach ($_POST['criteriaColumn'] as $value) { $parts = explode('.', $value); if (!empty($parts[0]) && !empty($parts[1])) { $table = str_replace('`', '', $parts[0]); $all_tables[$table] = $table; $all_columns[] = $table . '.' . str_replace('`', '', $parts[1]); } } // end while // Create LEFT JOINS out of Relations if (count($all_tables) > 0) { // Get tables and columns with valid where clauses $valid_where_clauses = $this->_getWhereClauseTablesAndColumns(); $where_clause_tables = $valid_where_clauses['where_clause_tables']; $where_clause_columns = $valid_where_clauses['where_clause_columns']; // Get master table $master = $this->_getMasterTable($all_tables, $all_columns, $where_clause_columns, $where_clause_tables); $from_clause = PMA_Util::backquote($master) . PMA_getRelatives($all_tables, $master); } // end if (count($all_tables) > 0) } // end count($_POST['criteriaColumn']) > 0 // In case relations are not defined, just generate the FROM clause // from the list of tables, however we don't generate any JOIN if (empty($from_clause) && isset($all_tables)) { $from_clause = implode(', ', $all_tables); } return $from_clause; }