我有一個store和store_details表,現在有一個store_details_stores表。HABTM關係中的搜索記錄 - CakePHP
的商店模式有以下幾點:
public $hasAndBelongsToMany = array('StoreDetail');
的StoreDetail模式有以下幾點:
public $hasAndBelongsToMany = array('Store');
當我試圖在stores_controller下面的查詢,我收到SQL錯誤。出於某種原因,store_details表格沒有自然加入。這是預期的行爲?我需要手動加入此表嗎?
$this->Store->find('all', array('conditions' => array('StoreDetail.name' => 'Parking')));
發佈SQL + Cake錯誤和查詢日誌將非常有幫助。 – sibidiba
它給出了一個SQL錯誤,因爲StoreDetail沒有被連接,所以StoreDetail.name不存在。乾杯。 – CrocHunter