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.
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/