开发者

How can I store a DateTime::Duration object in my DBI::Class model on a MySQL database?

开发者 https://www.devze.com 2023-01-03 20:46 出处:网络
I currently use the DBIx::Class::InflateColumn::DateTime plugin to inflate my date columns to DateTime objects and deflate my DateTime objects to MySQL date values.

I currently use the DBIx::Class::InflateColumn::DateTime plugin to inflate my date columns to DateTime objects and deflate my DateTime objects to MySQL date values.

I want to store the age of an individual (I cannot use DOB) and for this the years, months or days values may be 0. Therefore I am using a DateTime::Duration object. Thing is the plugin will fail if the value is not a valid date (and 0020-08-00 is not valid). Can I use the plugin, do I have to write my own or is there another way?

(BTW MySQL does allow开发者_运维知识库 such values - I am not concerned if it is 'invalid' - it works for what I need and I am not planning to change my RDBMS.)


So I ended writing my own InflateColumn module. You can find it on the CPAN

0

精彩评论

暂无评论...
验证码 换一张
取 消