Logical improvement in PMA_dbQbeGetOrderByClause

This commit is contained in:
Atul Pratap Singh 2012-07-10 21:26:45 +05:30
parent 7024c4df9b
commit 9fe3a570f0

View File

@ -673,25 +673,22 @@ function PMA_dbQbeGetOrderByClause($criteria_column_count)
{
$last_orderby = 0;
$orderby_clause = '';
for ($column_index = 0; $column_index < $criteria_column_count; $column_index++) {
if ($last_orderby
&& $column_index
&& ! empty($GLOBALS['curField'][$column_index])
&& ! empty($GLOBALS['curSort'][$column_index])
) {
$orderby_clause .= ', ';
}
for ($column_index = 0; $column_index < $criteria_column_count; $column_index++)
{
// if all columns are chosen with * selector, then sorting isn't available
// Fix for Bug #570698
if (! empty($GLOBALS['curField'][$column_index])
&& ! empty($GLOBALS['curSort'][$column_index])
) {
// if they have chosen all fields using the * selector,
// then sorting is not available
// Fix for Bug #570698
if (substr($GLOBALS['curField'][$column_index], -2) != '.*') {
$orderby_clause .= $GLOBALS['curField'][$column_index] . ' '
. $GLOBALS['curSort'][$column_index];
$last_orderby = 1;
if (substr($GLOBALS['curField'][$column_index], -2) == '.*') {
continue;
}
if ($last_orderby && $column_index) {
$orderby_clause .= ', ';
}
$orderby_clause .= $GLOBALS['curField'][$column_index] . ' '
. $GLOBALS['curSort'][$column_index];
$last_orderby = 1;
}
} // end for
if (! empty($orderby_clause)) {