From c0f129d5debf5bd4a030b8a53250fbabc781931a Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 2 Aug 2019 21:11:30 -0600 Subject: [PATCH] Add ability to set default column in order_by() function. --- resources/functions.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/resources/functions.php b/resources/functions.php index b9026bab06..dca5c9c479 100644 --- a/resources/functions.php +++ b/resources/functions.php @@ -2124,10 +2124,11 @@ function number_pad($number,$n) { //validate and format order by clause of select statement if (!function_exists('order_by')) { - function order_by($col, $dir) { + function order_by($col, $dir, $col_default = '') { $col = preg_replace('#[^a-zA-Z0-9-_.]#', '', $col); $dir = strtolower($dir) == 'desc' ? 'desc' : 'asc'; if ($col != '') { return ' order by '.$col.' '.$dir.' '; } + else if ($col_default != '') { return ' order by '.$col_default.' '.$dir.' '; } } }