[Catalyst] [DBIx::Class::ResultSet ] 'update' with 'where' clause
    John Romkey 
    romkey at apocalypse.org
       
    Tue Mar 23 18:30:07 GMT 2010
    
    
  
On Mar 23, 2010, at 2:15 PM, David 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')}});
This is really a DBIx::Class question and belongs on that list.
However.. you perform update on a resultset. $c->model() returns a resultset with no where clause. So get the resultset that you need with search and then call update() on that.
$c->model('DB::Test')->search({ 'id' => $c->user->get('id') })->update({'lang' => $lang->first->id});
	- john romkey
	http://www.romkey.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20100323/16fd8503/attachment.htm
    
    
More information about the Catalyst
mailing list