diff options
| author | winter | 2024-12-17 20:43:44 +0000 |
|---|---|---|
| committer | winter | 2024-12-17 20:43:44 +0000 |
| commit | 10793d22df72f12f2f14c730c09b5018b5b6e63a (patch) | |
| tree | ea3cf7cf1461b5b02d989d0077a154b6408948e8 /Digitigrade/Model.php | |
| parent | 12d3fe4509dda610e6b7adb120dc0530081c6768 (diff) | |
bugfixing
Diffstat (limited to 'Digitigrade/Model.php')
| -rw-r--r-- | Digitigrade/Model.php | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Digitigrade/Model.php b/Digitigrade/Model.php index 40e85f4..80a6d91 100644 --- a/Digitigrade/Model.php +++ b/Digitigrade/Model.php @@ -54,8 +54,15 @@ abstract class Model { $result = []; foreach ($props as $p) { $pName = $p->getName(); - if (!isset($this->{$pName})) - $this->{$pName} = null; + // set all nullable properties to null if they aren't already + if (!isset($this->{$pName})) { + try { + $this->{$pName} = null; + } catch (\TypeError $e) { + // if it can't be set, just ignore it + continue; + } + } // we need to determine the plain value to insert ... $value = $this->{$pName}; $discarded = false; |
