From d17fc238460887f9d5f754682e7bafc2e625428f Mon Sep 17 00:00:00 2001 From: KTP95 Date: Fri, 1 Jan 2016 20:01:22 +0100 Subject: [PATCH] fix $obj->relatedObj === null when not exists and fieldList $firstObj = file::with('secondObj')->ById($firstId,'FirstTableField, SecondTableField(s)NoPrimary'); print_r($firstObj->secondObj === null); BUT - WARNING - if SecondTableField(s)NoPrimary has a === null value , this return same $firstObj->secondObj === null as secondObj not exist... I don't know so fix this... anyway is a little bug. --- dbObject.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dbObject.php b/dbObject.php index 29fafdd4..7af2caa0 100644 --- a/dbObject.php +++ b/dbObject.php @@ -527,7 +527,13 @@ private function processAllWith (&$data, $shouldReset = true) { $data[$name] = $this->$name; continue; } - if ($data[$table][$primaryKey] === null) { + $hasOne = false; + foreach ($data[$table] as $field=>$value) { + if ($hasOne === true) continue; + if ($value !== null) $hasOne = true; + } + + if ($hasOne === false) { $data[$name] = null; } else { if ($this->returnType == 'Object') {