Forums / Developer / mySQL to ezPersistentObject 3.6.0 datatype mapping
Massimiliano Bariola
Wednesday 15 June 2005 3:50:46 am
hi,
I am using eZpersistentObject for a module I'm writing to interface with an external databse and its tables.
Browsing the code, I can see that there is mapping / handling for string and numeric int / float / double types. but how do I write the definition array for fields of date / datetime type?
e.g. from my own ezpersistentObject::definition method:
CreationDate is a mySQL datatype. I would like to write the definition snippet like this....
"creationDate" => array( 'name' => "CreationDate", 'datatype' => 'datetime', 'default' => '', 'required' => true ),
but it seems that eZContentObject has no special handling for dates/datetimes. Should I use the string datatype in definition and make sure myself that the datetime is correctly written to db?
TIA
Massimiliano
Björn X
Wednesday 15 June 2005 5:00:54 am
how about this?
"creationdate" => array( 'name' => "CreationDate", 'datatype' => 'integer', 'default' => time(),'required' => true ),
Wednesday 15 June 2005 6:07:41 am
Hi Bjorn,
first of all congrats on your lecture at eZcamp 2005.
your solution will work, but I cannot change the mySQL datastructure. I have to stick to the date/datetime columns.
How about if I set it as datatype => string, function_attributes =>array('myDateTimeField' => 'myDateGetterFunction'),set_functions => array('myDateTimeField' => 'myDateTimeSetterFunction')
could it work, in your opinion? I wasn't able to find any documentation for these features though, so it's just a stab in the dark ..