Fixed the function mysql_db_get_all_rows_in_table for several fields to order as array

(cherry picked from commit 36c5349cf4)
This commit is contained in:
mdtrooper 2015-04-20 16:24:08 +02:00
parent 5f60c5d5cc
commit cd0d2c68e5
1 changed files with 19 additions and 7 deletions

View File

@ -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 * @return mixed A matrix with all the values in the table
*/ */
function mysql_db_get_all_rows_in_table($table, $order_field = "", $order = 'ASC') { function mysql_db_get_all_rows_in_table($table, $order_field = "", $order = 'ASC') {
if ($order_field != "") { $sql = "
return db_get_all_rows_sql ("SELECT * SELECT *
FROM `".$table."` FROM `".$table."`";
ORDER BY ".$order_field . " " . $order);
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 { else {
return db_get_all_rows_sql ("SELECT * FROM `".$table."`"); $sql .= "
ORDER BY ".$order_field . " " . $order;
} }
}
return db_get_all_rows_sql($sql);
} }
/** /**