0
태그 및 MenuItem이 연결된 기사 모델이 있습니다. 특정 MenuItem ID를 가진 기사를 표시하려고합니다.CAKEPHP 다중 모델 필드 조건
프리폼이 모델에서 연산을 찾으면 ('필드 목록'에 알 수없는 'MenuItem.id'알 수없는) 오류가 반환됩니다.
내가 뭘 잘못하고 있는지 알고 있습니다.
제 모델 :
public $hasAndBelongsToMany = array(
'Tag' => array(
'className' => 'Tag',
'joinTable' => 'articles_tags',
'foreignKey' => 'article_id',
'associationForeignKey' => 'tag_id'
),
'MenuItem' => array(
'className' => 'MenuItem',
'joinTable' => 'menu_items_articles',
'foreignKey' => 'article_id',
'associationForeignKey' => 'menu_item_id',
'unique' => 'keepExisting'
)
);
제 컨트롤러 :
$allArticles = $this->Article->find('all',
array(
'fields' => array('MenuItem.id','Article.id','Article.name'),
'conditions'=>array('Article.content_type'=>'blog','MenuItem.id'=>7),
'recursive'=>2
)
);
debug($allArticles);
을 .. – Krishna
는 약간의 오타는'근처에있다 MenuItem.id ')'...하지만 작동합니다. 감사! 나는 containable이 최적화에 더 많은 것이라고 생각했으며, 왜 여전히 코드가 작동하지 않는지 궁금합니다. – waterschaats
여전히 작동하지 않는 것은 다음과 같은 조건을 추가 할 때입니다 :'array ('Article.content_type'=> 'blog', 'MenuItem.id'=> 7)' – waterschaats