Add auto-detected types from DB in ORM

This commit is contained in:
Alex Cabal 2022-02-22 10:49:54 -06:00
parent 7a11cacf6d
commit 58c0d301dd
3 changed files with 67 additions and 17 deletions

View file

@ -9,15 +9,7 @@ abstract class OrmBase{
public static function FillObject(Object $object, array $row): Object{
foreach($row as $property => $value){
if(substr($property, strlen($property) - 9) == 'Timestamp'){
if($value !== null){
$object->$property = new DateTime($value, new DateTimeZone('UTC'));
}
else{
$object->$property = null;
}
}
elseif(substr($property, strlen($property) - 5) == 'Cache'){
if(substr($property, strlen($property) - 5) == 'Cache'){
$property = substr($property, 0, strlen($property) - 5);
$object->$property = $value;
}