Bug #4258 Grid editing broken

Signed-off-by: Marc Delisle <marc@infomarc.info>
This commit is contained in:
Marc Delisle 2014-01-29 07:58:19 -05:00
parent 923448e635
commit f36fbfd4c6
2 changed files with 51 additions and 49 deletions

View File

@ -1019,7 +1019,7 @@ class PMA_Util
$sql_query, $GLOBALS['db']);
// Synchronize message(query) with table
PMA_handleSortOrder($GLOBALS['db'], $GLOBALS['table'],
self::handleSortOrder($GLOBALS['db'], $GLOBALS['table'],
$analyzed_sql_results, $sql_query);
}
@ -4371,6 +4371,54 @@ class PMA_Util
return $value . '.000000';
}
}
/**
* Handle remembered sorting order, only for single table 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
*/
public static function handleSortOrder(
$db, $table, &$analyzed_sql_results, &$full_sql_query
) {
$pmatable = new PMA_Table($table, $db);
if (empty($analyzed_sql_results['analyzed_sql'][0]['order_by_clause'])
&& isset($GLOBALS['default_query']) && $GLOBALS['default_query']) {
$sorted_col = $pmatable->getUiProp(PMA_Table::PROP_SORTED_COLUMN);
if ($sorted_col) {
//remove the tablename from retrieved preference
//to get just the column name and the sort order
$sorted_col = str_replace(
PMA_Util::backquote($table) . '.', '', $sorted_col
);
// retrieve the remembered sorting order for current table
$sql_order_to_append = ' ORDER BY ' . $sorted_col . ' ';
$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_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_results['analyzed_sql'][0]['order_by_clause']
);
}
}
}
?>

View File

@ -140,7 +140,7 @@ function PMA_getTableHtmlForMultipleQueries(
&& isset($analyzed_sql[0]['queryflags']['select_from'])
&& count($analyzed_sql[0]['table_ref']) == 1
) {
PMA_handleSortOrder(
PMA_Util::handleSortOrder(
$db,
$table,
$analyzed_sql,
@ -214,52 +214,6 @@ function PMA_getTableHtmlForMultipleQueries(
return $table_html;
}
/**
* Handle remembered sorting order, only for single table 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_results, &$full_sql_query)
{
$pmatable = new PMA_Table($table, $db);
if (empty($analyzed_sql_results['analyzed_sql'][0]['order_by_clause'])
&& isset($GLOBALS['default_query']) && $GLOBALS['default_query']) {
$sorted_col = $pmatable->getUiProp(PMA_Table::PROP_SORTED_COLUMN);
if ($sorted_col) {
//remove the tablename from retrieved preference
//to get just the column name and the sort order
$sorted_col = str_replace(
PMA_Util::backquote($table) . '.', '', $sorted_col
);
// retrieve the remembered sorting order for current table
$sql_order_to_append = ' ORDER BY ' . $sorted_col . ' ';
$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_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_results['analyzed_sql'][0]['order_by_clause']
);
}
}
/**
* Append limit clause to SQL query
*
@ -2282,7 +2236,7 @@ function PMA_executeQueryAndSendQueryResponse($analyzed_sql_results,
if (PMA_isRememberSortingOrder($analyzed_sql_results)
&& ! isset($analyzed_sql_results['analyzed_sql'][0]['queryflags']['union'])
) {
PMA_handleSortOrder($db, $table, $analyzed_sql_results, $full_sql_query);
PMA_Util::handleSortOrder($db, $table, $analyzed_sql_results, $full_sql_query);
}
// Do append a "LIMIT" clause?