Discussion:
Object of class DateTime could not be converted to string....
Daniel
2011-08-16 08:15:47 UTC
Permalink
When I have the annotations below in of my entities I get the error
below. If I remove the @ORM\Id part the error goes away. I did not
create this database and I dont even think the date field should be an
Id. This entity was generated by the Symfony command line interface. I
want to understand why this error is occurring.


/**
* @var datetime $date
*
* @ORM\Column(name="date", type="datetime", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="NONE")
*/


An exception has been thrown during the rendering of a template
("Catchable Fatal Error: Object of class DateTime could not be
converted to string in ....
--
If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to symfony2-/***@public.gmane.org
To unsubscribe from this group, send email to
symfony2+unsubscribe-/***@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
Christophe COEVOET
2011-08-16 08:27:07 UTC
Permalink
Post by Daniel
When I have the annotations below in of my entities I get the error
create this database and I dont even think the date field should be an
Id. This entity was generated by the Symfony command line interface. I
want to understand why this error is occurring.
/**
*
*/
An exception has been thrown during the rendering of a template
("Catchable Fatal Error: Object of class DateTime could not be
converted to string in ....
A datetime field cannot be used as id in Doctrine as the id has to be
castable as string. This is a known limitation in Doctrine that has been
qualified as "Won't fix" as adding logic to convert them to string would
have a performance impact on all queries.
--
Christophe | Stof
--
If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to symfony2-/***@public.gmane.org
To unsubscribe from this group, send email to
symfony2+unsubscribe-/***@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
Benjamin Eberlei
2011-08-16 08:44:32 UTC
Permalink
You can fix it yourself by overriding the DateTime type, creating datetime
subclasses that implement __toString()
Post by Daniel
When I have the annotations below in of my entities I get the error
Post by Daniel
create this database and I dont even think the date field should be an
Id. This entity was generated by the Symfony command line interface. I
want to understand why this error is occurring.
/**
*
*/
An exception has been thrown during the rendering of a template
("Catchable Fatal Error: Object of class DateTime could not be
converted to string in ....
A datetime field cannot be used as id in Doctrine as the id has to be
castable as string. This is a known limitation in Doctrine that has been
qualified as "Won't fix" as adding logic to convert them to string would
have a performance impact on all queries.
--
Christophe | Stof
--
If you want to report a vulnerability issue on symfony, please send it to
security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/**group/symfony2?hl=en<http://groups.google.com/group/symfony2?hl=en>
--
If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to symfony2-/***@public.gmane.org
To unsubscribe from this group, send email to
symfony2+unsubscribe-/***@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
Loading...