Allow user to chose whether to use joins or not

Signed-off-by: Madhura Jayaratne <madhura.cj@gmail.com>
This commit is contained in:
Madhura Jayaratne 2015-06-11 12:58:11 +05:30
parent 036d70aa8d
commit 27c259c7cb

View File

@ -1370,26 +1370,32 @@ class PMA_DbQbe
} }
} // end while } // end while
// Create LEFT JOINS out of Relations if (isset($_POST['useJoins'])) {
if (count($all_tables) > 0) { // Create LEFT JOINS out of Relations
// Get tables and columns with valid where clauses if (count($all_tables) > 0) {
$valid_where_clauses = $this->_getWhereClauseTablesAndColumns(); // Get tables and columns with valid where clauses
$where_clause_tables = $valid_where_clauses['where_clause_tables']; $valid_where_clauses = $this->_getWhereClauseTablesAndColumns();
$where_clause_columns = $valid_where_clauses['where_clause_columns']; $where_clause_tables = $valid_where_clauses['where_clause_tables'];
// Get master table $where_clause_columns = $valid_where_clauses['where_clause_columns'];
$master = $this->_getMasterTable( // Get master table
$all_tables, $all_columns, $master = $this->_getMasterTable(
$where_clause_columns, $where_clause_tables $all_tables, $all_columns,
); $where_clause_columns, $where_clause_tables
$from_clause = PMA_Util::backquote($master) );
. PMA_getRelatives($all_tables, $master); $from_clause = PMA_Util::backquote($master)
. PMA_getRelatives($all_tables, $master);
} // end if (count($all_tables) > 0) } // end if (count($all_tables) > 0)
}
// In case relations are not defined, just generate the FROM clause // In case relations are not defined, just generate the FROM clause
// from the list of tables, however we don't generate any JOIN // from the list of tables, however we don't generate any JOIN
if (empty($from_clause)) { if (empty($from_clause)) {
$from_clause = implode(', ', $all_tables); $backQuoted = array();
foreach ($all_tables as $table) {
$backQuoted[] = PMA_Util::backquote($table);
}
$from_clause = implode(', ', $backQuoted);
} }
} // end count($_POST['criteriaColumn']) > 0 } // end count($_POST['criteriaColumn']) > 0
@ -1432,6 +1438,14 @@ class PMA_DbQbe
$html_output .= $this->_getSavedSearchesField(); $html_output .= $this->_getSavedSearchesField();
} }
$html_output .= '<br />';
$html_output .= '<input type="checkbox" id="useJoins" name="useJoins" value="true"';
if (isset($_REQUEST['useJoins'])) {
$html_output .= ' checked="checked"';
}
$html_output .= ' />';
$html_output .= '<label for="useJoins" />' . __('Use joins') . '</label>';
$html_output .= '<table class="data" style="width: 100%;">'; $html_output .= '<table class="data" style="width: 100%;">';
// Get table's <tr> elements // Get table's <tr> elements
$html_output .= $this->_getColumnNamesRow(); $html_output .= $this->_getColumnNamesRow();