From cd0d2c68e5c15331a2321771bf7d529cdba547c1 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Mon, 20 Apr 2015 16:24:08 +0200 Subject: [PATCH] Fixed the function mysql_db_get_all_rows_in_table for several fields to order as array (cherry picked from commit 36c5349cf46d75739aad15d62b29be7fe7cbdbe7) --- pandora_console/include/db/mysql.php | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/pandora_console/include/db/mysql.php b/pandora_console/include/db/mysql.php index fd904bb0ad..da202fb0c3 100644 --- a/pandora_console/include/db/mysql.php +++ b/pandora_console/include/db/mysql.php @@ -181,14 +181,26 @@ function mysql_db_get_row ($table, $field_search, $condition, $fields = false) { * @return mixed A matrix with all the values in the table */ function mysql_db_get_all_rows_in_table($table, $order_field = "", $order = 'ASC') { - if ($order_field != "") { - return db_get_all_rows_sql ("SELECT * - FROM `".$table."` - ORDER BY ".$order_field . " " . $order); - } - else { - return db_get_all_rows_sql ("SELECT * FROM `".$table."`"); + $sql = " + SELECT * + FROM `".$table."`"; + + if (!empty($order_field)) { + if (is_array($order_field)) { + foreach ($order_field as $i => $o) { + $order_field[$i] = $o . " " . $order; + } + $sql .= " + ORDER BY " . implode(",", $order_field); + } + else { + $sql .= " + ORDER BY ".$order_field . " " . $order; + } + } + + return db_get_all_rows_sql($sql); } /**