[Catalyst] model update

Tobias Kremer list at funkreich.de
Mon Feb 25 21:31:40 GMT 2008


Am 25.02.2008 um 21:56 schrieb Jennifer Ahn:

>   my $obj = $c->model ('MyAppDB::Student')->update (
>       { name => $name     },
>       { id => $id}
>       );
> I'm updating the name field where the id field is given for the  
> model called Student.  i'm not sure why, but the code above updates  
> ALL row name fields, not just rows with the particular id.   is the  
> syntax wrong? my

Try:

$c->model( 'MyAppDB::Student' )->find( $id )->update( { name =>  
$name } );

Assuming 'id' is defined as your primary key.

--Tobias




More information about the Catalyst mailing list