I have solved by this way:
namespace spa\doctrine\dbal;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\DateTimeType as DoctrineDateTimeType;
use Doctrine\DBAL\Types\DateTimeTzType as DoctrineDateTimeTzType;
class DateTimeType extends DoctrineDateTimeType {
public function convertToPHPValue($value, AbstractPlatform $platform)
{
if ($value=='infinity' || $value=='-infinity') return $value;
return parent::convertToPHPValue($value,$platform);
}
}
class DateTimeTzType extends DoctrineDateTimeTzType {
public function convertToPHPValue($value, AbstractPlatform $platform)
{
if ($value=='infinity' || $value=='-infinity') return $value;
return parent::convertToPHPValue($value,$platform);
}
}
Type::overrideType(Type::DATETIME,'spa\doctrine\dbal\DateTimeType');
Type::overrideType(Type::DATETIMETZ,'spa\doctrine\dbal\DateTimeTzType');
суббота, 6 декабря 2014 г., 18:58:34 UTC+3 пользователь Pavel Sokolov
написал:
>
> I have postgres database which use 'infinity' as value for datetime fields.
>
> I got error when I try to read this value from database:
> *Could not convert database value "infinity" to Doctrine Type datetimetz.
> Expected format: Y-m-d H:i:sO*
>
> So, how can I setup custom format converter to fix this error?
>
--
You received this message because you are subscribed to the Google Groups
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.