[Dbix-class] DateTime independant from the database

Ronald J Kimball rkimball+dbixclass at pangeamedia.com
Thu May 22 16:26:03 BST 2008


To use DateTime for inflating your date columns, all you need to do is 
add InflateColumn::DateTime to the list of components.  So, change:

__PACKAGE__->load_components("Core");

to:

__PACKAGE__->load_components("InflateColumn::DateTime", "Core");


You don't need to re-add the line of code to add the column, if it's 
already there.  As long as the column is of type datetime, date, or 
timestamp, the inflation/deflation will be applied to it automatically.


Ronald


hallouina-dbix at yahoo.fr wrote:
> Hi everybody,
> 
> I'm new and happy to use DBIx.
> 
> I'm creating
> a little Catalyst application. I have a forms and use FormFu to create
> it. I full it almost completly and need to complete 2 others date field
> int the controller. I have created a sql file then generate my schema.
> I never modified my schema in catalyst.
> I want to keep a model that
> stay database independant. So I want to used
> DBIx::Class::InflateColumns::DateTime (as Jess Robinson advise me on
> irc). But the documentation about this module is not very expensive.
> 
> On my Project.pm I have this warning :
> 
> # Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-05-01 01:36:27
> # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:tS5sQsszV7IB1uRDv4CfdA
> 
> 
> So
> I try to add 
> __PACKAGE__->load_components('InflateColumn::DateTime');  at the end
> of Project.pm . And as the documentation say, to add a date I should do
> something like :
> 
> 
> __PACKAGE__->add_columns(
>     datecreation => { data_type => 'datetime' }
>   );
> 
> But the field "datecreation" already exist and as say the warning, I sould not modify anything above.
> 
> So how could I do to solve my problem please ? I just want to add 2 dates before saving my form.
> 
> Have someone a way, a tutorial or some clue to help me please ?

> Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.rawmode.org




More information about the DBIx-Class mailing list