1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
--- phpMyAdmin-2.11.9-all-languages-utf-8-only/libraries/database_interface.lib.php 2008-08-28 18:48:52.000000000 +0200
+++ phpMyAdmin-2.11.9.1-all-languages-utf-8-only/libraries/database_interface.lib.php 2008-09-15 18:38:06.000000000 +0200
@@ -188,6 +188,32 @@
}
/**
+ * usort comparison callback
+ *
+ * @param string $a first argument to sort
+ * @param string $b second argument to sort
+ *
+ * @return integer a value representing whether $a should be before $b in the
+ * sorted array or not
+ *
+ * @global string the column the array shall be sorted by
+ * @global string the sorting order ('ASC' or 'DESC')
+ *
+ * @access private
+ */
+function PMA_usort_comparison_callback($a, $b)
+{
+ if ($GLOBALS['cfg']['NaturalOrder']) {
+ $sorter = 'strnatcasecmp';
+ } else {
+ $sorter = 'strcasecmp';
+ }
+ // produces f.e.:
+ // return -1 * strnatcasecmp($a["SCHEMA_TABLES"], $b["SCHEMA_TABLES"])
+ return ($GLOBALS['callback_sort_order'] == 'ASC' ? 1 : -1) * $sorter($a[$GLOBALS['callback_sort_by']], $b[$GLOBALS['callback_sort_by']]);
+} // end of the 'PMA_usort_comparison_callback()' function
+
+/**
* returns array of all tables in given db or dbs
* this function expects unquoted names:
* RIGHT: my_database
@@ -543,23 +569,10 @@
* (caused by older MySQL < 5 or $GLOBALS['cfg']['NaturalOrder'])
*/
if ($apply_limit_and_order_manual) {
-
- /**
- * first apply ordering
- */
- if ($GLOBALS['cfg']['NaturalOrder']) {
- $sorter = 'strnatcasecmp';
- } else {
- $sorter = 'strcasecmp';
- }
-
- // produces f.e.:
- // return -1 * strnatcasecmp($a["SCHEMA_TABLES"], $b["SCHEMA_TABLES"])
- $sort_function = '
- return ' . ($sort_order == 'ASC' ? 1 : -1) . ' * ' . $sorter . '($a["' . $sort_by . '"], $b["' . $sort_by . '"]);
- ';
-
- usort($databases, create_function('$a, $b', $sort_function));
+ $GLOBALS['callback_sort_order'] = $sort_order;
+ $GLOBALS['callback_sort_by'] = $sort_by;
+ usort($databases, 'PMA_usort_comparison_callback');
+ unset($GLOBALS['callback_sort_order'], $GLOBALS['callback_sort_by']);
/**
* now apply limit
|