Functions: Updates for PHP 8.1

This commit is contained in:
fusionate
2023-05-12 00:45:09 +00:00
parent 1986dc1ae7
commit 733b206664

View File

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