特定のタグまたはタグを持つ投稿のページネーションを使用して検索を実行しようとしています (たとえば、ユーザーが 2 つのタグを選択すると、いずれかのタグを含む投稿が返されます)。
Posts テーブルで定義された関係があります
public $hasAndBelongsToMany = array('Tags' => array(
'className' => 'Tags',
'joinTable' => 'posts_tags',
'foreignKey' => 'post_id',
'associationForeignKey' => 'tag_id',
'unique' => 'keepExisting'));
Find を使用して特定のタグを持つ行を取得するにはどうすればよいですか (名前または ID で問題ありません)
しようとしている:
// other pagination settings goes here
$this->paginate['conditions']['Tags.id'] = 13;
関係が存在しないというエラーが表示されます。
デバッグ情報を見ると、テーブルが Posts_Tags および Tags テーブルに参加していないように見えますが、データをデバッグしてビューに表示すると、Posts オブジェクトにタグ データが含まれています。
これについて私が見つけることができるドキュメントのほとんどは、CakePHP の以前のバージョンを中心に展開しているようです。