[CDBI] before and after update values in before_update trigger

Sorin Milutinovici sorin-cdbi at contentlogic.ro
Tue May 2 09:19:11 BST 2006


On Monday 01 May 2006 14:02, Daniel Williams wrote:
> my @log_cols = qw/column1 column2 column3 column4/;
>
> Blah->add_trigger( map { 'before_set_'. $_ => \&col_saver } @log_cols )
> ;
> Blah->add_trigger( before_update => \&before_update ) ;
>
> sub col_saver {
>     my $self = shift ;
>     return unless (ref($self)) ;
>     my ($new, $argsR) = @_ ;
>
>     foreach my $key (keys %$argsR) {
>         $self->{cdbi_oldvals}->{$key} = $self->get($key) ;
>     }
> }
>
> sub before_update {
>         my $self = shift;
>         # Old Value
>         $self->{cdbi_oldvals}->{column}
>         # New Value
>         $self->column;
> }

Thanks. It works.

-- 
Semper in excrementul sole profundum qui variat




More information about the ClassDBI mailing list