Allow usage of bool types on the ORM.

This commit is contained in:
kj 2022-08-01 08:27:49 -04:00
parent 8d47e10d7a
commit 08d92a2b81
1 changed files with 9 additions and 9 deletions

View File

@ -236,20 +236,20 @@ class Model {
$properties = $reflection->getProperties(ReflectionProperty::IS_PUBLIC); $properties = $reflection->getProperties(ReflectionProperty::IS_PUBLIC);
$result = []; $result = [];
foreach($properties as $property) { foreach($properties as $property)
$att = $property->name; $result[$property->name] = isset($this->{$property->name})
$result[$att] = isset($this->$att) ? $this->{$property->name} : null;
? $this->$att : null;
}
foreach (static::$ignoreSave as $del) { foreach (static::$ignoreSave as $del)
unset($result[$del]); unset($result[$del]);
}
foreach (static::$forceSave as $value) { foreach (static::$forceSave as $value)
$result[$value] = isset($this->$value) $result[$value] = isset($this->$value)
? $this->$value: null; ? $this->$value: null;
}
foreach ($result as $i => $property)
if (gettype($property) == 'boolean')
$result[$i] = $property ? '1' : '0';
return $result; return $result;
} }