Re: [CDBI] before and after update values in before_update trigger

Sorin Milutinovici <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.class-dbi
Organization ContentLogic
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.