W bazie jest tabela:
Countries - country_id | country_name
i
Voivodships - voivod_id | country_id | itd.

<!--Geshi:233516:php--><pre class="php-brief" style="font-family:monospace;"><div class="head">
  1. [topic=0]o</span> <span class="sy0">=</span> [url="http://www.php.net/array"]<span class="kw3">array</span>[/url]<span class="br0">(</span><span class="st0">'country'</span><span class="br0">)</span><span class="sy0">;</span></div><li class="li1"><div class="de1"> protected <span class="re0">$primary_key</span> <span class="sy0">=</span> <span class="st0">'voivod_id'</span><span class="sy0">;</span></div>
  2. [/list]<div class="foot">[PHP] [url="./Pobierz-Plik-233517.html"]plaintext[/url] </div></pre><!--/Geshi:233517:php-->
  3.  
  4. Robię:
  5.  
  6. [php]
  7. $this -> countries = ORM::factory("country");
  8.  
  9. $countries = $this -> countries -> getAll();
  10. foreach($countries as $c) {
  11. echo $c->country_id;
  12. foreach($c->voivodships as $d){ echo $d->voivod_name; }
  13. }


I otrzymuje:

  1. Wystąpił błąd SQL: Nieznana kolumna 'voivodships.country_country_id' w where clause - SELECT `voivodships`.* FROM (`voivodships`) WHERE `voivodships`.`country_country_id` = 1 ORDER BY `voivodships`.`voivod_id` ASC



@edit

ok, protected $foreign_key = array('voivodships' => 'country_id');