[Dbix-class] chained 'search' then 'update'

Matt Lawrence matt.lawrence at ymogen.net
Wed Mar 5 10:22:33 GMT 2008


Angel Kolev wrote:
> Hi, all.
>
> I have a table with fields 'id' and 'status'. Status is ENUM field 
> with values 'active' and 'backup'. I need somethink like(i use dbic in 
> catalyst):
>
> my $rs = $c->model('ModelDB::CheckMap')->search({id => 
> $id})->update('status','backup');
> $rs->create({%params});
>
> I have to change the status of all old fields for id $id to 'backup' 
> then create new fields. Can i change this status in one pass like 
> example above?
>
As far as I can see, the only problem with the line you have is that 
update expects a hashref.

Matt



More information about the DBIx-Class mailing list