Commit 679191a4 authored by guilhermeblanco's avatar guilhermeblanco

[2.0][DDC-30] Fixed null values with Date, Time and DateTime types. Thanks...

[2.0][DDC-30] Fixed null values with Date, Time and DateTime types. Thanks Ismo for report and patch
parent dce2d790
......@@ -23,11 +23,13 @@ class DateTimeType extends Type
public function convertToDatabaseValue($value, AbstractPlatform $platform)
{
return $value->format($platform->getDateTimeFormatString());
return ($value !== null)
? $value->format($platform->getDateTimeFormatString()) : null;
}
public function convertToPHPValue($value, AbstractPlatform $platform)
{
return \DateTime::createFromFormat($platform->getDateTimeFormatString(), $value);
return ($value !== null)
? \DateTime::createFromFormat($platform->getDateTimeFormatString(), $value) : null;
}
}
\ No newline at end of file
......@@ -23,11 +23,13 @@ class DateType extends Type
public function convertToDatabaseValue($value, AbstractPlatform $platform)
{
return $value->format($platform->getDateFormatString());
return ($value !== null)
? $value->format($platform->getDateFormatString()) : null;
}
public function convertToPHPValue($value, AbstractPlatform $platform)
{
return \DateTime::createFromFormat($platform->getDateFormatString(), $value);
return ($value !== null)
? \DateTime::createFromFormat($platform->getDateFormatString(), $value) : null;
}
}
\ No newline at end of file
......@@ -31,7 +31,8 @@ class TimeType extends Type
*/
public function convertToDatabaseValue($value, AbstractPlatform $platform)
{
return $value->format($platform->getTimeFormatString());
return ($value !== null)
? $value->format($platform->getTimeFormatString()) : null;
}
/**
......@@ -41,6 +42,7 @@ class TimeType extends Type
*/
public function convertToPHPValue($value, AbstractPlatform $platform)
{
return \DateTime::createFromFormat($platform->getTimeFormatString(), $value);
return ($value !== null)
? \DateTime::createFromFormat($platform->getTimeFormatString(), $value) : null;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment