title: How to join tables using ORM in Kohana
body: <p>Im as u can see in my history kinda new into kohana, but learning quick.. I am struggling on a weird problem that worked before in Kohana 3.3</p>
  
  <p>I want to create a join query between two databases. i created the Model_Veiligen en Model_Veilingvoorkeur models, and put this as ORM call:</p>
  
  <p>This is the RIGHT JOIN QUERY:</p>
  
  <pre><code> SELECT `vastprijs`, `veilingen`.`id` AS `id`, `veilingen`.`gid` AS `gid`, `veilingen`.`provincie` AS `provincie`, `veilingen`.`created` AS `created`, `veilingen`.`termtime` AS `termtime`, `veilingen`.`postcode` AS `postcode`, `veilingen`.`lat` AS `lat`, `veilingen`.`lng` AS `lng`, `veilingen`.`titel` AS `titel`, `veilingen`.`beschrijving` AS `beschrijving`, `veilingen`.`images` AS `images`, `veilingen`.`ip` AS `ip`, `veilingen`.`unique` AS `unique` FROM `veilingen` AS `veilingen` RIGHT JOIN `veilingvoorkeur` ON (`veilingen`.`id` = `vid`) ORDER BY `veilingen`.`created` DESC LIMIT 10
  </code></pre>
  
  <p>DIT IS DE LEFT:</p>
  
  <pre><code>SELECT `vastprijs`, `veilingen`.`id` AS `id`, `veilingen`.`gid` AS `gid`,     `veilingen`.`provincie` AS `provincie`, `veilingen`.`created` AS `created`,     `veilingen`.`termtime` AS `termtime`, `veilingen`.`postcode` AS `postcode`,     `veilingen`.`lat` AS `lat`, `veilingen`.`lng` AS `lng`, `veilingen`.`titel` AS `titel`,     `veilingen`.`beschrijving` AS `beschrijving`, `veilingen`.`images` AS `images`,     `veilingen`.`ip` AS `ip`, `veilingen`.`unique` AS `unique` FROM `veilingen` AS `veilingen`     LEFT JOIN `veilingvoorkeur` ON (`veilingen`.`id` = `vid`) ORDER BY `veilingen`.`created` DESC LIMIT 10
  </code></pre>
  
  <p>RIGHT JOIN output:</p>
  
  <pre><code>[_object:protected] =&gt; Array ( [id] =&gt; [gid] =&gt; [provincie] =&gt; [created] =&gt; [termtime] =&gt; [postcode] =&gt; [lat] =&gt; [lng] =&gt; [titel] =&gt; [beschrijving] =&gt; [images] =&gt; [ip] =&gt; [unique] =&gt; [vastprijs] =&gt; 56 ) 
  </code></pre>
  
  <p>LEFT JOIN OUTPUT:</p>
  
  <pre><code>[_object:protected] =&gt; Array ( [id] =&gt; 121 [gid] =&gt; 10 [provincie] =&gt; 9 [created] =&gt; 1385534362 [termtime] =&gt; 1386743962 [postcode] =&gt; 8031CJ [lat] =&gt; 52.528510 [lng] =&gt; 6.081043 [titel] =&gt; gdfgd [beschrijving] =&gt; fgfdgdfgfdsfsfd [images] =&gt; [{"file_name":"5a5a7a7ef44.png","file_size":238687,"file_type":"image\/png","file_link":"uploads\/\/5a5a7a7ef44.png"}] [ip] =&gt; 94.215.33.178 [unique] =&gt; [vastprijs] =&gt; )
  </code></pre>
  
  <p>My code for the Left or right join is as follows:</p>
  
  <pre><code>$veiling = ORM::factory('veilingen')
          -&gt;select('vastprijs')
          -&gt;join('veilingvoorkeur', 'RIGHT')
          -&gt;on('veilingen.id', '=', 'vid')
          -&gt;order_by('veilingen.created', DESC)
          -&gt;limit(10)
          -&gt;find_all();
  </code></pre>
  
  <p>The problem im hanging into is that i don't understand the has_many and belongs_to, the example above worked before, but not anymore. </p>
  
  <p>The problem that occurs if i change RIGHT in LEFT, it will output all data from the veilingen table. But it ignores the data of the vastprijs field. But if i print the foreach element, i can see that the vastprijs has been selected. Except for data.</p>
  
  <p>If i use RIGHT, instead of left. above story occurs but then otherwise. vastprijs isn't empty and veilingen fields are empty. but shown.</p>
  
  <hr>
  
  <p>My main question is, how can i relate those 2 tables together with maybe has_many, but veilingen only has_one veilingvoorkeur. The key is veilingen.id = veilingvoorkeur.vid</p>