我有以下表格:在Yii框架中是否有像“has_one:through(from Rails)”?
manufacturers
* id
* name
* description
types
* id
* name
* description
* manufacturer_id
cars
* id
* title
* description
* type_id
现在我的问题是,我想与类型和manufacurers,例如列出汽车:
* Some Car, Fiat Punto
* Another Car, Ferrari F1
...
在铁轨我可以与制造商建立关系。像这样:
class Car < ActiveRecord::Base
belongs_to :type
has_one :manufacturer, :through => :type
end
这在Yii中也是可行的吗?
谢谢。这也是我目前的解决方案(将manufacturer_id插入类型和汽车中)。但是,在汽车表中没有manufacturer_id的情况下可以创建关系吗? – ipsum 2011-01-30 20:15:07