我有以下表格:在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