set empty result set as null

This commit is contained in:
Dennis Eichhorn 2017-09-14 11:05:25 +02:00
parent cb0a443c55
commit 8a6659cdd2

View File

@ -1765,7 +1765,7 @@ class DataMapperAbstract implements DataMapperInterface
} }
if (in_array(static::$columns[$column]['type'], ['string', 'int', 'float', 'bool'])) { if (in_array(static::$columns[$column]['type'], ['string', 'int', 'float', 'bool'])) {
if($reflectionProperty->getValue($obj) !== null) { if($reflectionProperty->getValue($obj) !== null || $value !== null) {
settype($value, static::$columns[$column]['type']); settype($value, static::$columns[$column]['type']);
} }
@ -1872,7 +1872,15 @@ class DataMapperAbstract implements DataMapperInterface
self::fillRelations($obj, $relations); self::fillRelations($obj, $relations);
self::clear(); self::clear();
return count($obj) === 1 ? reset($obj) : $obj; $countResulsts = count($obj);
if($countResulsts === 0) {
return null;
} elseif($countResulsts === 1) {
return reset($obj);
}
return $obj;
} }
/** /**