From 5668e7f90808318f48b1cc305cebafcd79945850 Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Sun, 15 Jul 2012 13:26:36 +0530 Subject: Form function to get the master table --- db_qbe.php | 41 +++-------------------------------------- 1 file changed, 3 insertions(+), 38 deletions(-) (limited to 'db_qbe.php') diff --git a/db_qbe.php b/db_qbe.php index fed91dd01b..def2d03b6c 100644 --- a/db_qbe.php +++ b/db_qbe.php @@ -300,44 +300,9 @@ if (isset($criteriaColumn) && count($criteriaColumn) > 0) { unset($tab_raw); unset($col_raw); unset($col1); - - if (count($tab_wher) == 1) { - // If there is exactly one column that has a decent where-clause - // we will just use this - $master = key($tab_wher); - } else { - // Now let's find out which of the tables has an index - // (When the control user is the same as the normal user - // because he is using one of his databases as pmadb, - // the last db selected is not always the one where we need to work) - $col_cand = PMA_dbQbeGetLeftJoinColumnCandidates( - $db, $tab_all, $col_all, $col_where - ); - - // If our array of candidates has more than one member we'll just - // find the smallest table. - // Of course the actual query would be faster if we check for - // the Criteria which gives the smallest result set in its table, - // but it would take too much time to check this - if (count($col_cand) > 1) { - // Of course we only want to check each table once - $checked_tables = $col_cand; - foreach ($col_cand as $tab) { - if ($checked_tables[$tab] != 1) { - $tsize[$tab] = PMA_Table::countRecords($db, $tab, false); - $checked_tables[$tab] = 1; - } - $csize[$tab] = $tsize[$tab]; - } - asort($csize); - reset($csize); - $master = key($csize); // Smallest - } else { - reset($col_cand); - $master = current($col_cand); // Only one single candidate - } - } // end if (exactly one where clause) - + $master = PMA_dbQbeGetMasterTable( + $db, $tab_all, $col_all, $col_where, $tab_wher + ); $tab_left = $tab_all; unset($tab_left[$master]); $tab_know[$master] = $master; -- cgit v1.2.3