From 99cf4c8da2ab7de9fbd401f5dd31db9664b28c0e Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Tue, 13 Aug 2024 13:23:51 +0200 Subject: [PATCH] Improve the Model "optional" method functionality for empty values --- application/core/EA_Model.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application/core/EA_Model.php b/application/core/EA_Model.php index 52be38f2..7fbfc73a 100644 --- a/application/core/EA_Model.php +++ b/application/core/EA_Model.php @@ -189,12 +189,12 @@ class EA_Model extends CI_Model { if (is_assoc($record)) { foreach ($fields as $field => $default) { - $record[$field] = $record[$field] ?? $default; + $record[$field] = $record[$field] ?? null ?: $default; } } else { foreach ($record as &$record_item) { foreach ($fields as $field => $default) { - $record_item[$field] = $record_item[$field] ?? $default; + $record_item[$field] = $record_item[$field] ?? null ?: $default; } } }