diff --git a/libraries/DBQbe.class.php b/libraries/DBQbe.class.php index 2724b8f757..14cddd2757 100644 --- a/libraries/DBQbe.class.php +++ b/libraries/DBQbe.class.php @@ -1304,23 +1304,23 @@ class PMA_DbQbe /** * Provides UNIQUE columns and INDEX columns present in criteria tables * - * @param array $all_tables Tables involved in the search - * @param array $all_columns Columns involved in the search + * @param array $search_tables Tables involved in the search + * @param array $search_columns Columns involved in the search * @param array $where_clause_columns Columns having criteria where clause * * @return array having UNIQUE and INDEX columns */ - private function _getIndexes($all_tables, $all_columns, + private function _getIndexes($search_tables, $search_columns, $where_clause_columns ) { $unique_columns = array(); $index_columns = array(); - foreach ($all_tables as $table) { + foreach ($search_tables as $table) { $indexes = $GLOBALS['dbi']->getTableIndexes($this->_db, $table); foreach ($indexes as $index) { $column = $table . '.' . $index['Column_name']; - if (isset($all_columns[$column])) { + if (isset($search_columns[$column])) { if ($index['Non_unique'] == 0) { if (isset($where_clause_columns[$column])) { $unique_columns[$column] = 'Y'; @@ -1347,27 +1347,27 @@ class PMA_DbQbe /** * Provides UNIQUE columns and INDEX columns present in criteria tables * - * @param array $all_tables Tables involved in the search - * @param array $all_columns Columns involved in the search + * @param array $search_tables Tables involved in the search + * @param array $search_columns Columns involved in the search * @param array $where_clause_columns Columns having criteria where clause * * @return array having UNIQUE and INDEX columns */ - private function _getLeftJoinColumnCandidates($all_tables, $all_columns, + private function _getLeftJoinColumnCandidates($search_tables, $search_columns, $where_clause_columns ) { $GLOBALS['dbi']->selectDb($this->_db); // Get unique columns and index columns $indexes = $this->_getIndexes( - $all_tables, $all_columns, $where_clause_columns + $search_tables, $search_columns, $where_clause_columns ); $unique_columns = $indexes['unique']; $index_columns = $indexes['index']; list($candidate_columns, $needsort) = $this->_getLeftJoinColumnCandidatesBest( - $all_tables, $where_clause_columns, $unique_columns, $index_columns + $search_tables, $where_clause_columns, $unique_columns, $index_columns ); // If we came up with $unique_columns (very good) or $index_columns (still @@ -1403,14 +1403,14 @@ class PMA_DbQbe /** * Provides the main table to form the LEFT JOIN clause * - * @param array $all_tables Tables involved in the search - * @param array $all_columns Columns involved in the search + * @param array $search_tables Tables involved in the search + * @param array $search_columns Columns involved in the search * @param array $where_clause_columns Columns having criteria where clause * @param array $where_clause_tables Tables having criteria where clause * * @return string table name */ - private function _getMasterTable($all_tables, $all_columns, + private function _getMasterTable($search_tables, $search_columns, $where_clause_columns, $where_clause_tables ) { if (count($where_clause_tables) == 1) { @@ -1425,7 +1425,7 @@ class PMA_DbQbe // because he is using one of his databases as pmadb, // the last db selected is not always the one where we need to work) $candidate_columns = $this->_getLeftJoinColumnCandidates( - $all_tables, $all_columns, $where_clause_columns + $search_tables, $search_columns, $where_clause_columns ); // Generally, we need to display all the rows of foreign (referenced) @@ -1537,27 +1537,27 @@ class PMA_DbQbe $from_clause = ''; if (isset($_POST['criteriaColumn']) && count($_POST['criteriaColumn']) > 0) { // Initialize some variables - $all_tables = $all_columns = array(); + $search_tables = $search_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]); + $search_tables[$table] = $table; + $search_columns[] = $table . '.' . str_replace('`', '', $parts[1]); } } // end while // Create LEFT JOINS out of Relations - $from_clause = $this->_getJoinForFromClause($all_tables, $all_columns); + $from_clause = $this->_getJoinForFromClause($search_tables, $search_columns); // 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)) { // Create cartesian product $from_clause = implode( - ", ", array_map('PMA_Util::backquote', $all_tables) + ", ", array_map('PMA_Util::backquote', $search_tables) ); } } // end count($_POST['criteriaColumn']) > 0 @@ -1568,19 +1568,19 @@ class PMA_DbQbe /** * Formulates the WHERE clause by JOINing tables * - * @param array $allTables Tables involved in the search - * @param array $allColumns Columns involved in the search + * @param array $searchTables Tables involved in the search + * @param array $searchColumns Columns involved in the search * * @return string table name */ - private function _getJoinForFromClause($allTables, $allColumns) + private function _getJoinForFromClause($searchTables, $searchColumns) { // $relations[master_table][foreign_table] => clause $relations = array(); // Fill $relations with inter table relationship data - foreach ($allTables as $oneTable) { + foreach ($searchTables as $oneTable) { $relations[$oneTable] = array(); $foreigners = PMA_getForeigners($GLOBALS['db'], $oneTable); @@ -1621,7 +1621,7 @@ class PMA_DbQbe // Get master table $master = $this->_getMasterTable( - $allTables, $allColumns, + $searchTables, $searchColumns, $whereClauseColumns, $whereClauseTables ); @@ -1644,14 +1644,14 @@ class PMA_DbQbe $added = true; } elseif (! isset($finalized[$foreignTable]) && isset($finalized[$masterTable]) - && in_array($foreignTable, $allTables) + && in_array($foreignTable, $searchTables) ) { $finalized[$foreignTable] = $clause; $added = true; } if ($added) { // We are done if all tables are in $finalized - if (count($finalized) == count($allTables)) { + if (count($finalized) == count($searchTables)) { break 3; } } @@ -1665,7 +1665,7 @@ class PMA_DbQbe // Tables that can not be combined with the table cluster // that includes master table - $unfinalized = array_diff($allTables, array_keys($finalized)); + $unfinalized = array_diff($searchTables, array_keys($finalized)); // Add these tables as cartesian product before joined tables $join = implode(', ', array_map('PMA_Util::backquote', $unfinalized)); @@ -1855,7 +1855,7 @@ class PMA_DbQbe /** * Get best * - * @param array $all_tables All tables + * @param array $search_tables Tables involved in the search * @param array $where_clause_columns Columns with where clause * @param array $unique_columns Unique columns * @param array $index_columns Indexed columns @@ -1863,7 +1863,7 @@ class PMA_DbQbe * @return array */ private function _getLeftJoinColumnCandidatesBest( - $all_tables, $where_clause_columns, $unique_columns, $index_columns + $search_tables, $where_clause_columns, $unique_columns, $index_columns ) { // now we want to find the best. if (isset($unique_columns) && count($unique_columns) > 0) { @@ -1879,7 +1879,7 @@ class PMA_DbQbe $needsort = 0; return array($candidate_columns, $needsort); } else { - $candidate_columns = $all_tables; + $candidate_columns = $search_tables; $needsort = 0; return array($candidate_columns, $needsort); }