[Dbix-class] DateTime independant from the database

hallouina-dbix at yahoo.fr hallouina-dbix at yahoo.fr
Thu May 22 23:57:30 BST 2008


Indeed "datecreation" was already created and was database independant.

What I was searching to do, is to complete a table row with a form. My table row was almost full, but I had to fill 2 date field. And now it's done and it work. I believed it come from the date, but it was an other field that wasn't correctly completed.

Thanks for all with my DBIc problem ;).

Antoine.

----- Message d'origine ----
De : Byron Young <Byron.Young at riverbed.com>
À : DBIx::Class user and developer list <dbix-class at lists.scsys.co.uk>
Envoyé le : Jeudi, 22 Mai 2008, 1h30mn 01s
Objet : RE: [Dbix-class] DateTime independant from the database

Hey Antoine.

hallouina-dbix at yahoo.fr wrote on 2008-05-21:
> 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

Can you explain what you're trying to do a little better?  Do you need another datetime field in your model, or are you combining two fields with some date math and storing that in your current datecreation field?


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

Looks like DBIx::Class::Schema::Loader already added the datecreation field, so you don't need to add it again.


> So how could I do to solve my problem please ? I just want to add 2
> dates before saving my form.
>

What's the problem exactly?  If you need to add a column to your table, I would suggest updating the table and regenerating your schema using DBIx::Class::Schema::Loader.  You could add new columns by hand, but I don't think mixing the two approaches is a good idea.

Byron

__________________________________________________
Do You Yahoo!?
En finir avec le spam? Yahoo! Mail vous offre la meilleure protection possible contre les messages non sollicités 
http://mail.yahoo.fr Yahoo! Mail 



More information about the DBIx-Class mailing list