1
0
mirror of synced 2024-12-14 07:06:04 +03:00

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

This commit is contained in:
guilhermeblanco 2009-10-03 16:05:49 +00:00
parent dce2d79046
commit 679191a426
3 changed files with 12 additions and 6 deletions

View File

@ -23,11 +23,13 @@ class DateTimeType extends Type
public function convertToDatabaseValue($value, AbstractPlatform $platform) 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) public function convertToPHPValue($value, AbstractPlatform $platform)
{ {
return \DateTime::createFromFormat($platform->getDateTimeFormatString(), $value); return ($value !== null)
? \DateTime::createFromFormat($platform->getDateTimeFormatString(), $value) : null;
} }
} }

View File

@ -23,11 +23,13 @@ class DateType extends Type
public function convertToDatabaseValue($value, AbstractPlatform $platform) 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) public function convertToPHPValue($value, AbstractPlatform $platform)
{ {
return \DateTime::createFromFormat($platform->getDateFormatString(), $value); return ($value !== null)
? \DateTime::createFromFormat($platform->getDateFormatString(), $value) : null;
} }
} }

View File

@ -31,7 +31,8 @@ class TimeType extends Type
*/ */
public function convertToDatabaseValue($value, AbstractPlatform $platform) 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) public function convertToPHPValue($value, AbstractPlatform $platform)
{ {
return \DateTime::createFromFormat($platform->getTimeFormatString(), $value); return ($value !== null)
? \DateTime::createFromFormat($platform->getTimeFormatString(), $value) : null;
} }
} }