Kohana 2.3.4 ORM - Access data from pivot table

373 views Asked by At

im trying to access data stored on a pivot table with no success...

My tables and Models are these:

*Countries
-id
-name
-code_name
-active

*Sites
-id
-season_id
-title
-active

Countries_Sites:
-country_id
-site_id
-year

class Site_Model extends ORM {

  protected $has_and_belongs_to_many = array('countries');
}

class Country_Model extends ORM {

  protected $has_and_belongs_to_many = array('sites');
}

I wonder if there is a builtin method or something to access the "year" value of the pivot table.

Thanks!

1

There are 1 answers

0
George On

You need a has_many "through" relationship. see here: http://docs.kohanaphp.com/libraries/orm/advanced#has_many_through_relationships