<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 18, 2014 at 12:50 PM, Peter Rabbitson <span dir="ltr"><<a href="mailto:rabbit+dbic@rabbit.us" target="_blank">rabbit+dbic@rabbit.us</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 11/18/2014 12:36 PM, RAPPAZ Francois wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Thanks for replying !<br>
<br>
So it's a feature, not a bug ?<br>
</blockquote>
<br></span>
It's neither, it has to do with design.<span class=""><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
In mysql, I can execute<br>
"update `ddrefs` inner join `ddusers` using (iduser) set id_credit = 22 WHERE ddrefs.iduser = 3"<br>
</blockquote>
<br></span>
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:<br>
<br>
$s->resultset('Ddref')-><u></u>search(<br>
{ 'RefUser.iduser' => 3 },<br>
{ join => 'RefUser' }<br>
)->update({ id_credit => 22 });<br>
<br>
Again - you need to internalize the difference between the Result and ResultSet concepts, they are not interchangeable (if anything - they are orthogonal).</blockquote><div><br></div><div>What really made it "click" for me was realizing that I should think of a ResultSet, not primarily as a collection of rows, but rather as an SQL query under construction (that might eventually get executed by calling ->first, ->next, ->all, etc...).</div><div><br></div><div>In reality, of course, ResultSets behave as both, but the part about it being a query-in-the-making is a subtle yet profound aspect that enables all sorts of interesting design patterns.</div><div><br></div><div>It took me too long to realize this when I started out with DBIC - probably because our code base made almost no use of it...</div><div><br></div><div>/L</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">
<br>
______________________________<u></u>_________________<br>
List: <a href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class" target="_blank">http://lists.scsys.co.uk/cgi-<u></u>bin/mailman/listinfo/dbix-<u></u>class</a><br>
IRC: <a href="http://irc.perl.org#dbix-class" target="_blank">irc.perl.org#dbix-class</a><br>
SVN: <a href="http://dev.catalyst.perl.org/repos/bast/DBIx-Class/" target="_blank">http://dev.catalyst.perl.org/<u></u>repos/bast/DBIx-Class/</a><br>
Searchable Archive: <a href="http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk" target="_blank">http://www.grokbase.com/group/<u></u>dbix-class@lists.scsys.co.uk</a><br>
</div></div></blockquote></div><br></div></div>