[CDBI] HOW TO populate creation date automatically?

Vitaliy Babiy vitaliy.babiy at gmail.com
Sat Dec 31 22:40:03 GMT 2005


Hi 

I have table with column 'dateCreated' which supposed to have date when
record was created. How can I populate that field automatically with
CDBI?

I tried to use trigger 'before_create' to populate that field, but it
doesn't work. What I'm missing here?

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

Regards, Vit





More information about the ClassDBI mailing list