Forums / Developer / mySQL to ezPersistentObject 3.6.0 datatype mapping

mySQL to ezPersistentObject 3.6.0 datatype mapping

Author Message

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 [email protected]

Wednesday 15 June 2005 5:00:54 am

how about this?

"creationdate" => array( 'name' => "CreationDate",
'datatype' => 'integer',
'default' => time(),
'required' => true ),

Looking for a new job? http://www.xrow.com/xrow-GmbH/Jobs
Looking for hosting? http://hostingezpublish.com
-----------------------------------------------------------------------------
GMT +01:00 Hannover, Germany
Web: http://www.xrow.com/

Massimiliano Bariola

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 ..