0
檢索字段我有以下三個數據庫表:如何從鏈接模型
Products
########
id
title
artist_id
Arists
######
id
profile
person_id
People
######
id
first_name
last_name
在我Product
模型如何創建一個方法來一起退回產品title
藝術家的first_name
?
我已經建立了以下模型關聯:
Product belongs to Artist
Artist belongs to Person
什麼是實際的語法只是呼應了名字? – freshest
請參閱'print_r'查看路徑。如果你使用'$ products = $ this-> Product-> find('all')'我想它會出現在'$ products [0] ['Artist'] ['People'] ['first_name']'中。 – gustavotkg
使用'$ products [0] ['Artist'] ['Person'] ['first_name']'工作,但是使用這種方法會拖出大量不必要的數據,有沒有更好的方法來做到這一點? – freshest