[Catalyst] model update

Alex Povolotsky tarkhil at over.ru
Sat Mar 8 18:24:39 GMT 2008


Jennifer Ahn wrote:
> hello!
>
> i'm writing my first controller method to update the database using 
> the catalyst model, but  i seem to have the syntax for that all wrong.
>
>    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 understanding was that the first hash is to specify the set 
> values and the second hash specifies the "where" clause of a query..

First of all, $c->model('Model::Class') returns DBIx::ResultSet, NOT 
YourApp::Schema::Class. It is quite unclear for me, and seems to be 
illogical, but it is.

Second, update() syntax in your example is incorrect.

Alex.




More information about the Catalyst mailing list