CakePHP:如何在连接表中插入一行


CakePHP: How to insert a row into a join table

我有两个模型/表,有一个"有和属于许多" (HABTM)关系:QsetsQuestions

我可以手动删除行,如下所示:

$this->Qset->QsetsQuestion->deleteAll( array("QsetsQuestion.qset_id"=>$qset_id, "QsetsQuestion.question_id"=>$question_id), false );

如何在连接表中插入新行?我找到的使用HABTM数据的任何文档都是专门指表单的,但我的数据不是来自表单。

我想大概是这样的:

$data = array(
    [Question] => Array
        (
            [id] => $question_id
        )
    [Qset] => Array
        (
            [id] => $qset_id
        )
);
$this->Question->saveAll($data);