Re: [CDBI] Re: HOW TO populate creation date automatically?

[prev] [thread] [next] [Date index for 2006/01/09]

From: Vitaliy Babiy
Subject: Re: [CDBI] Re: HOW TO populate creation date automatically?
Date: 00:25 on 09 Jan 2006
Hey

> In general, you don't want to use set() or get() from inside a trigger, since
> they invoke triggers themselves. _attribute_store() is the correct method to
> use here. Refer to the documentation for evidence:
> 
> http://search.cpan.org/dist/Class-DBI/lib/Class/DBI.pm#LOW-LEVEL_DATA_ACCESS

This exactly what I'm doing. But I can not understand why it's not
working. Am I missing something?


__PACKAGE__->add_trigger( before_create  => 
     sub { my $self = shift;                         
           $self->_attribute_store( { 
                   dateCreated => Class::Date->now } );
         } );

I checked log and it's obvious that 'dateCreated' field is not populated
when record is created in DB. I use MySQL, by the way.

Regards, Vitaliy


_______________________________________________
ClassDBI mailing list
ClassDBI@xxxxx.xxxxxxxxxxxxxxxx.xxx
http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi

(message missing)

[CDBI] Simple join
Jon Molin 00:16 on 30 Dec 2005

Re: [CDBI] Simple join
Peter Speltz 20:13 on 30 Dec 2005

Re: [CDBI] Re: HOW TO populate creation date automatically?
Vitaliy Babiy 00:25 on 09 Jan 2006

Generated at 01:21 on 10 Jan 2006 by mariachi v0.52