[Dbix-class] DBIc-Class-ResultSet

Matt S Trout dbix-class at trout.me.uk
Sat Apr 8 15:30:06 CEST 2006


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.

-- 
      Matt S Trout       Offering custom development, consultancy and support
   Technical Director    contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

+ Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +



More information about the Dbix-class mailing list