Skip to content

Commit

Permalink
Merge pull request #527 from scnakandala/gsoc_2013_2
Browse files Browse the repository at this point in the history
Bug Fix
  • Loading branch information
lem9 committed Jul 19, 2013
2 parents f26b076 + d15028e commit a961e21
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
29 changes: 17 additions & 12 deletions libraries/sql.lib.php
Expand Up @@ -217,34 +217,39 @@ function PMA_getTableHtmlForMultipleQueries(
/**
* Handle remembered sorting order, only for single table query
*
* @param string $db database name
* @param string $table table name
* @param array &$analyzed_sql the analyzed query
* @param string &$full_sql_query SQL query
* @param string $db database name
* @param string $table table name
* @param array &$analyzed_sql_results the analyzed query results
* @param string &$full_sql_query SQL query
*
* @return void
*/
function PMA_handleSortOrder($db, $table, &$analyzed_sql, &$full_sql_query)
function PMA_handleSortOrder($db, $table, &$analyzed_sql_results, &$full_sql_query)
{
$pmatable = new PMA_Table($table, $db);
if (empty($analyzed_sql[0]['order_by_clause'])) {
if (empty($analyzed_sql_results['analyzed_sql'][0]['order_by_clause'])) {
$sorted_col = $pmatable->getUiProp(PMA_Table::PROP_SORTED_COLUMN);
if ($sorted_col) {
// retrieve the remembered sorting order for current table
$sql_order_to_append = ' ORDER BY ' . $sorted_col . ' ';
$full_sql_query = $analyzed_sql[0]['section_before_limit']
. $sql_order_to_append . $analyzed_sql[0]['limit_clause']
. ' ' . $analyzed_sql[0]['section_after_limit'];
$full_sql_query
= $analyzed_sql_results['analyzed_sql'][0]['section_before_limit']
. $sql_order_to_append
. $analyzed_sql_results['analyzed_sql'][0]['limit_clause']
. ' '
. $analyzed_sql_results['analyzed_sql'][0]['section_after_limit'];

// update the $analyzed_sql
$analyzed_sql[0]['section_before_limit'] .= $sql_order_to_append;
$analyzed_sql[0]['order_by_clause'] = $sorted_col;
$analyzed_sql_results['analyzed_sql'][0]['section_before_limit']
.= $sql_order_to_append;
$analyzed_sql_results['analyzed_sql'][0]['order_by_clause']
= $sorted_col;
}
} else {
// store the remembered table into session
$pmatable->setUiProp(
PMA_Table::PROP_SORTED_COLUMN,
$analyzed_sql[0]['order_by_clause']
$analyzed_sql_results['analyzed_sql'][0]['order_by_clause']
);
}
}
Expand Down
5 changes: 3 additions & 2 deletions sql.php
Expand Up @@ -172,15 +172,16 @@

// Handle remembered sorting order, only for single table query
if (PMA_isRememberSortingOrder($analyzed_sql_results)) {
PMA_handleSortOrder($db, $table, $analyzed_sql, $full_sql_query);
PMA_handleSortOrder($db, $table, $analyzed_sql_results, $full_sql_query);
}

// Do append a "LIMIT" clause?
if (PMA_isAppendLimitClause($analyzed_sql_results)) {
list($sql_limit_to_append,
$full_sql_query, $analyzed_display_query, $display_query
) = PMA_appendLimitClause(
$full_sql_query, $analyzed_sql, isset($display_query)
$full_sql_query, $analyzed_sql_results['analyzed_sql'],
isset($display_query)
);
} else {
$sql_limit_to_append = '';
Expand Down

0 comments on commit a961e21

Please sign in to comment.