0
InventoryCategoryのサマリーを見ると、インベントリは取得できますが、InventoryImagesは取得できません。 CakePHPによって報告されたエラーは[Model "Inventory"はモデル "InventoryImage"に関連付けられていません。これらは私が使用していたモデルです。CakePHPモデル拡張アソシエーション
class InventoryCategory extends InventoriesAppModel {
public $hasMany =
array(
'Inventory'
, 'InventoryCategoryImage' => array
(
'className' => 'Media.MediaImage'
, 'foreignKey' => 'foreign_key'
, 'conditions' => array(
'InventoryCategoryImage.model' => 'InventoryCategoryImage'
, 'InventoryCategoryImage.group' => 'Inventory Category Image'
,
)
, 'dependent' => true
,
)
,
);
public function containedModels()
{
$contain = array(
'Inventory'
, 'InventoryCategoryImage'
,
);
return $contain;
}
}
class Inventory extends InventoriesAppModel {
public $belongsTo =
array(
'User'
, 'InventoryCategory'
,
);
public $hasMany =
array(
'InventoryImage' => array
(
'className' => 'Media.MediaImage'
, 'foreignKey' => 'foreign_key'
, 'conditions' => array(
'InventoryImage.model' => 'InventoryImage'
, 'InventoryImage.group' => 'Inventory Image'
,
)
, 'dependent' => true
, 'order' => 'InventoryImage.rank ASC, InventoryImage.id ASC'
)
,
);
public function containedModels()
{
$contain = array(
'User'
, 'InventoryCategory'
,
);
return $contain;
}
}
があなたの検索では=> 2 ' ' '再帰的な' です()を呼び出しますか?また、そのエラーを示す検索呼び出しを投稿してください。 – Costa
いいえ、再帰的に使用しません。代わりにContainを含む。 – radarhill
'code'public関数ビュー(){ 場合 {\tの$ this - >リダイレクト(の$ this - >リファラ()()の$ this - > paramsは[ 'ID']!)。 } $条件\t =(is_numeric($ this-> params ['id'])) \t \t \t?配列($ this-> modelClass。 '.id =' => $ this-> params ['id']) \t \t \t:array($ this-> modelClass。 '.slug =' => $ this-> params ['id']); $項目\t \t = $この - > {の$ this - > modelClass} - >検索( '第' \t \t \t \t \t \t、アレイ( \t \t \t \t '条件' \t => $条件 を\t \t \t \t、\t => $これを '含む' - > {の$ this - > modelClass} - > containedModels() \t \t \t) \t); $ this-> set(compact( 'item')); } 'code' – radarhill