【问题标题】:Kohana 2.3.4 ORM - Access data from pivot tableKohana 2.3.4 ORM - 从数据透视表访问数据
【发布时间】:2012-04-13 19:04:01
【问题描述】:

我试图访问存储在数据透视表上的数据但没有成功...

我的表格和模型如下:

*国家
-id
-名称
-code_name
-主动

*网站
-id
-season_id
-标题
-主动

Countries_Sites:
-country_id
-site_id
- 年

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');
}

我想知道是否有内置方法或其他东西可以访问数据透视表的“年份”值。

谢谢!

【问题讨论】:

    标签: php orm relational-database kohana-2


    【解决方案1】:

    您需要一个 has_many “通过”关系。看这里:http://docs.kohanaphp.com/libraries/orm/advanced#has_many_through_relationships

    【讨论】:

      猜你喜欢
      • 2011-02-06
      • 1970-01-01
      • 1970-01-01
      • 2010-12-29
      • 2022-06-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多