[Dbix-class] DBIc-Class-ResultSet

Kjell Arne Arvesen kjell.arvesen at siegedesign.no
Sun Apr 9 13:18:12 CEST 2006


Matt S Trout wrote:

>Kjell Arne Arvesen wrote:
>  
>
>>Hiya.
>>
>>I've created an instance of DBIx::Class::ResultSet for a table class 
>>called user where I have the following method:
>>
>>Example:
>>sub update_email {
>>    ...
>>    my $rs = $self->search({...}); # This returns a proper resultset
>>    my @users = $rs->all; #Returns an array containing all the data for 
>>each users
>>    my $count = 1;
>>    foreach my $user ( @users ) {
>>       print "User name ".$user->name." Email: ".$user->email."\n"; # 
>>Prints the name and the email
>>       my $email = $user->email;
>>       $email =~ s/$count\@userDomain/$count\@userDomain2/gi; # Makes 
>>stopid email adresses :)
>>       $user->email($email) # We now change the default domain name for 
>>all the users
>>       $user->update; # This never happens!
>>       $count++;
>>    }
>>    ...
>>}
>>
>>The update call never happens and I don't understand why.
>>    
>>
>
>I don't think your s/// is actually doing anything. Which means that nothing's 
>been changed on the object, so when you call ->update on it DBIx::Class 
>doesn't both issuing an UPDATE query since there's nothing to put in it.
>
>  
>
I've even tried to do a $user->email("doh") and then call the update 
method. Still nothing happens.

- Kjell Arne



More information about the Dbix-class mailing list