diff --git a/libraries/display_tbl.lib.php b/libraries/display_tbl.lib.php index cfa794596..640466ec8 100644 --- a/libraries/display_tbl.lib.php +++ b/libraries/display_tbl.lib.php @@ -448,7 +448,7 @@ onsubmit="return (checkFormElementInRange(this, 'session_max_rows', ''; } else { @@ -1744,16 +1744,18 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql) // we need $sort_expression and $sort_expression_nodirection // even if there are many table references - - $sort_expression = trim(str_replace(' ', ' ', $analyzed_sql[0]['order_by_clause'])); - - /** - * Get rid of ASC|DESC - * @todo analyzer - */ - preg_match('@(.*)([[:space:]]*(ASC|DESC))@si', $sort_expression, $matches); - $sort_expression_nodirection = isset($matches[1]) ? trim($matches[1]) : $sort_expression; - unset($matches); + if (! empty($analyzed_sql[0]['order_by_clause'])) { + $sort_expression = trim(str_replace(' ', ' ', $analyzed_sql[0]['order_by_clause'])); + /** + * Get rid of ASC|DESC + */ + preg_match('@(.*)([[:space:]]*(ASC|DESC))@si', $sort_expression, $matches); + $sort_expression_nodirection = isset($matches[1]) ? trim($matches[1]) : $sort_expression; + $sort_direction = isset($matches[2]) ? trim($matches[2]) : ''; + unset($matches); + } else { + $sort_expression = $sort_expression_nodirection = $sort_direction = ''; + } // 1.4 Prepares display of first and last value of the sorted column @@ -1894,7 +1896,7 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql) // end 2b // 3. ----- Displays the results table ----- - PMA_displayTableHeaders($is_display, $fields_meta, $fields_cnt, $analyzed_sql, $sort_expression, $sort_expression_nodirection); + PMA_displayTableHeaders($is_display, $fields_meta, $fields_cnt, $analyzed_sql, $sort_expression, $sort_expression_nodirection, $sort_direction); $url_query = ''; echo '
' . "\n"; PMA_displayTableBody($dt_result, $is_display, $map, $analyzed_sql);