私のcakephpのアプリケーションは、私が唯一の製品モデルの内容は、(ProductDimensionを製品の関連付けを取得する方法があります来ているすべてのカテゴリーの要素を見つけています関係船cakephpの検索再帰協会
class Category extends AppModel {
public $hasAndBelongsToMany = array(
'Product' => array(
'className' => 'Product',
'joinTable' => 'products_categories',
'foreignKey' => 'category_id',
'associationForeignKey' => 'product_id',
'unique' => 'keepExisting',
),
);
}
class Product extends AppModel {
public $primaryKey = 'id';
public $hasMany = array(
'ProductSwatch' => array(
'className' => 'ProductSwatch',
'foreignKey' => 'product_id',
'dependent' => true
),
'ProductDimension' => array(
'className' => 'ProductDimension',
'foreignKey' => 'product_id',
'dependent' => true
),
'ProductCare' => array(
'className' => 'ProductCare',
'foreignKey' => 'product_id',
'dependent' => true
),
'ProductDimension' => array(
'className' => 'ProductDimension',
'foreignKey' => 'product_id',
'dependent' => false,
),
'ProductCare' => array(
'className' => 'ProductCare',
'foreignKey' => 'product_id',
'dependent' => false,
),
'Review' => array(
'className' => 'Review',
'foreignKey' => 'product_id',
'dependent' => true,
)
);
}
と、次のモデルを持っていますProductSwatches、etc.)を参照してください。
が使用ContainableBehavior http://book.cakephp.org/2.0/en/core-libraries/behaviors/containable.html – Salines
常にタグを含めてください見ます使用しているCakePHPのバージョン。 – Dave