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/
_______________________________________________
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/