[Catalyst] [DBIx::Class::ResultSet ] 'update' with 'where' clause

Ben Vinnerd ben-catalyst at vinnerd.com
Tue Mar 23 18:29:00 GMT 2010


Hi David,

You need to call either update or update_all on the ResultSet. See docs:
http://search.cpan.org/~ribasushi/DBIx-Class-0.08120/lib/DBIx/Class/ResultSet.pm#update
http://search.cpan.org/~ribasushi/DBIx-Class-0.08120/lib/DBIx/Class/ResultSet.pm#update_all

Try something like this:

$c->model('DB::Test')->search({id => $c->user->get('id'))->update({lang =>
$lang->first->id});

Ben


On Tue, 23 Mar 2010 18:15:55 +0000 (GMT), David <oldskiffle at yahoo.es>
wrote:
> Hi,
> 
> I can't find how to set 'where' clause in an update. I only want to
update
> rows depending on a condition. Is that possible? 
> I haven't this option in ResultSet documentation.
> 
> I try like next, but it doesn't work. It updates all table rows.
> 
> $c->model('DB::Test')->update({'lang' => $lang->first->id},{where =>
{'id'
> => $c->user->get('id')}});
> 
>  
> 
> Thanks in advanced,
> 
> David



More information about the Catalyst mailing list