Ver código fonte

Functions: Updates for PHP 8.1

fusionate 2 anos atrás
pai
commit
89d57534b0
1 arquivos alterados com 15 adições e 9 exclusões
  1. 15 9
      resources/functions.php

+ 15 - 9
resources/functions.php

@@ -1218,6 +1218,7 @@ function number_pad($number,$n) {
 
 				//return adjusted color in format received
 				if (isset($hash) && $hash == '#') { //hex
+					$hex = '';
 					for ($i = 0; $i <= 2; $i++) {
 						$hex_color = dechex($color[$i]);
 						if (strlen($hex_color) == 1) { $hex_color = '0'.$hex_color; }
@@ -2042,16 +2043,21 @@ 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 = 0) {
+		function limit_offset($limit = null, $offset = 0) {
 			$regex = '#[^0-9]#';
-			$limit = preg_replace($regex, '', $limit);
-			$offset = preg_replace($regex, '', $offset ?? '');
-			if (is_numeric($limit) && $limit > 0) {
-				$clause = ' limit '.$limit;
-				$offset = is_numeric($offset) ? $offset : 0;
-				$clause .= ' offset '.$offset;
-			}
-			return $clause.' ';
+			if (!empty($limit)) {
+				$limit = preg_replace($regex, '', $limit);
+				$offset = preg_replace($regex, '', $offset ?? '');
+				if (is_numeric($limit) && $limit > 0) {
+					$clause = ' limit '.$limit;
+					$offset = is_numeric($offset) ? $offset : 0;
+					$clause .= ' offset '.$offset;
+				}
+				return $clause.' ';
+			}
+			else {
+				return '';
+			}
 		}
 	}