There are two model class
class Tags{
public $id;
public $name;
public function initialize(){
$this->setSource('Tags');
$this->hasManyToMany(
"id",
"TaggedQuestions",
"tag_id",
"question_id",
"Questions",
"id"
);
}}
class Questions {
public $id;
public $title;
public $description;
public function initialize(){
$this->setSource('Questions');
$this->hasManyToMany(
"id",
"TaggedQuestions",
"question_id",
"tag_id",
"Tags",
"id"
);
}
}
After question->create(), records would be duplicated on junction table as listed below
id tag_id question_id
79 73 25
80 74 25
81 75 25
82 73 25
83 74 25
84 75 25