title: How do PHP ORMs map results to objects (hydration)
body: <p>If I run a query simialr to:</p>
  
  <pre><code>SELECT * FROM user u
  LEFT JOIN orders o ON o.user_id=u.id
  LEFT JOIN payments p ON p.order_id=o.id
  </code></pre>
  
  <p>Resulting in data like:</p>
  
  <pre><code>u.id, u.name, o.id, o.item, o.date_time, p.id, p.amount, p.date_time
    99    jeff    17  spring   12-12-2012    12     10.99   13-12-2012
    99    jeff    18     jam   12-12-2012    13       .99   16-12-2012
    99    jeff    19     car   22-12-2012    14      1000   17-12-2012
    99    jeff    19     car   22-12-2012    15      1000   18-12-2012
    99    jeff    19     car   22-12-2012    16      1000   19-12-2012
  </code></pre>
  
  <p>So user Jeff has 3 orders, he has made 3 payments towards his car.</p>
  
  <p>Give the PHP objects User, Order and Payment and a single DB query - how do they get hydrated? I would like to see pseudo-code, actual php code or the pattern name I should read up on :)</p>