Class::DBI::FromCGI and is_changed

[prev] [thread] [next] [Date index for 2004/10/26]

From: Simon Wilcox
Subject: Class::DBI::FromCGI and is_changed
Date: 12:45 on 26 Oct 2004
Hi all,

I am using Class::DBI::FromCGI to update some user preferences. Updating
is happening fine but I need to detect when the user has submitted the
form without changing any of the fields.

I thought that I could use ->is_changed but that thinks that the fields
*have* been changed, maybe by the act of untainting them ?

Is that the expected behaviour or have I done something silly ? In the
event of the former, is there any way to work out what has actually
changed other than by comparing the fields in a foreach loop before trying
the update ?

Many thanks,

Simon.

The code looks like:

    $user->update_from_cgi( $h => { required => \@must_have,
                                    all => \@columns_to_update } );

    if (my %errors = $user->cgi_update_errors) {
        $user->discard_changes;
        die( Template::Exception->new( 'DATA-ERROR',
                                       \%errors ));
    }elsif ( $user->is_changed ){
        warn "updated : ".join( ':', $user->is_changed )."\n";
        $user->update;
        #$user->dbi_commit;
        return 1;
    }else{
        #nothing changed !
        return 0;
    }

Class::DBI::FromCGI and is_changed
Simon Wilcox 12:45 on 26 Oct 2004

Re: Class::DBI::FromCGI and is_changed
Tony Bowden 18:38 on 26 Oct 2004

RE: Class::DBI::FromCGI and is_changed
Zhuang Li 18:51 on 26 Oct 2004

RE: Class::DBI::FromCGI and is_changed
Simon Wilcox 18:56 on 26 Oct 2004

RE: Class::DBI::FromCGI and is_changed
Charles Bailey 19:05 on 26 Oct 2004

RE: Class::DBI::FromCGI and is_changed
Kingsley Kerce 19:42 on 26 Oct 2004

Re: Class::DBI::FromCGI and is_changed
Tony Bowden 08:31 on 27 Oct 2004

Generated at 11:34 on 01 Dec 2004 by mariachi v0.52