Model hasAndBelongsToManyï¼HABTMï¼ã¯postã«è¨å®ãã¾ãã models > post.php class Post extends AppModel { public $name = 'Post'; public $hasAndBelongsToMany = array( 'Tag' => array( 'className' => 'Tag', 'joinTable' => 'posts_tags', 'foreignKey' => 'post_id', 'associationForeignKey' => 'tag_id', 'fields' => array('id','name'), 'unique' => true ), ); } models > tag.php class Tag extends AppModel { public $name
{{#tags}}- {{label}}
{{/tags}}