From fad7c24b90b9c4b72ff186291cf245c29db68de5 Mon Sep 17 00:00:00 2001 From: Nate Date: Mon, 1 Jul 2019 20:52:54 -0600 Subject: [PATCH] limit_offset() function refinement --- resources/functions.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/resources/functions.php b/resources/functions.php index d19e43d99f..2e96aeb0e5 100644 --- a/resources/functions.php +++ b/resources/functions.php @@ -2133,15 +2133,14 @@ function number_pad($number,$n) { //validate and format limit and offset clause of select statement if (!function_exists('limit_offset')) { - function limit_offset($limit, $offset) { + function limit_offset($limit, $offset = 0) { $regex = '#[^0-9]#'; $limit = preg_replace($regex, '', $limit); $offset = preg_replace($regex, '', $offset); if (is_numeric($limit) && $limit > 0) { $clause .= ' limit '.$limit; - if (is_numeric($offset)) { - $clause .= ' offset '.$offset; - } + $offset = is_numeric($offset) ? $offset : 0; + $clause .= ' offset '.$offset; } return $clause.' '; }