[Dbix-class] update and join

Peter Rabbitson rabbit+dbic at rabbit.us
Sat Dec 20 15:08:02 GMT 2014


On 11/13/2014 12:34 PM, RAPPAZ Francois wrote:
> I have two tables joined by a "belongs to" and a "has many" relationship
>        Ddref
>             idref iduser finished created
>             n    n--------------+
>             ^                   ¦
>             ¦                   ¦RefUser (bt iduser)
>             ¦UserRef (hm)       ¦
>             ¦                   ¦
>             1     1<------------+
>             Dduser
>             iduser email id_credit
>
> I would like to update the field id_credit in Ddref :
> my $href2 = {
> 		  '+select' => [  'RefUser.id_credit', 'RefUser.email'],
> 			'+as' => [qw/id_credit email/],
> 		  order_by => 'created',
> 		  join => ['RefUser']};
>
> my $href = {idref => 24 };
> my $rs1 = $s->resultset('Ddref')->search_rs($href, $href2);
> my $row = $rs1->single;
> 	$row->set_column('id_credit' => 28);
> 	$row->update();
>
> But update fails with since the sql is
> UPDATE ddrefs SET id_credit = ? WHERE ( idref = ? )" with ParamValues: 0=28, 1='24'
>

Hi Francois,

I just wanted to check with you whether you ended up with a reasonable 
answer to your question, or if you are still confused.

Thanks!




More information about the DBIx-Class mailing list