[Dbix-class] Update a related table

Dermot paikkos at googlemail.com
Mon Jul 14 17:13:58 BST 2008


Hi,

I am sure this is a simple task but I don't appear to be getting it.

t1 has a column in which I store the id for the members of t2

I can do this:

my $data_from_t1 = $c->model('MyDB::MyData')->find({'sub_id' => $id});

and I can retrieve the other table object from $data_from_t1 by

$data_from_t2 = $data_from_t1->t1_column_ref

But what if, in the process of updating t1, I want to update a field
in a related record in t2. I can't seem to find a way to do that.

I have tried

$data_from_t2->field_to_update = 1;
$data_from_t2->update;
$data_from_t1_update;

Can someone point me in the right direction?
Thanx,
Dp.



More information about the DBIx-Class mailing list