[Dbix-class] update and join

Peter Rabbitson rabbit+dbic at rabbit.us
Tue Nov 18 11:50:43 GMT 2014


On 11/18/2014 12:36 PM, RAPPAZ Francois wrote:
> Thanks for replying !
>
> So it's a feature, not a bug ?

It's neither, it has to do with design.

> In mysql, I can execute
> "update `ddrefs` inner join `ddusers` using (iduser) set id_credit = 22 WHERE ddrefs.iduser = 3"

A similar (though *not* identical) effect can be achieved by operating 
on a ResultSet (not Result). Given your original example, the above 
would look something like:

$s->resultset('Ddref')->search(
   { 'RefUser.iduser' => 3 },
   { join => 'RefUser' }
)->update({ id_credit => 22 });

Again - you need to internalize the difference between the Result and 
ResultSet concepts, they are not interchangeable (if anything - they are 
orthogonal).



More information about the DBIx-Class mailing list