Browse files

Bug #4258 Grid editing broken

Signed-off-by: Marc Delisle <marc@infomarc.info>
  • Loading branch information...
1 parent 923448e commit f36fbfd4c6fde0aa771e8e51de09de2b34e4ecb1 @lem9 lem9 committed Jan 29, 2014
Showing with 51 additions and 49 deletions.
  1. +49 −1 libraries/Util.class.php
  2. +2 −48 libraries/sql.lib.php
View
50 libraries/Util.class.php
@@ -1019,7 +1019,7 @@ public static function getMessage(
$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 @@ public static function addMicroseconds($value)
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
50 libraries/sql.lib.php
@@ -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,
@@ -215,52 +215,6 @@ 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_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
*
* @param string $full_sql_query 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?

0 comments on commit f36fbfd

Please sign in to comment.