我卡在 Cake PHP 代码中的多级关联表上。
我有以下型号
有很多学生的监护人,不同的学生有他们的学生费。当我创建一个有 2 个学生的监护人时,必须为 StudentFees 表创建关联的 2 行。添加监护人时我成功添加了2名学生,但我不知道如何为学生添加2行费用。我的代码如下。
class Guardian extends AppModel {
public $name = 'Guardian';
public $recursive =2;
public $hasMany = array(
'Student' => array(
'className' => 'Student',
'dependent' => true
)
);
}
class Student extends AppModel {
public $name = 'Student';
public $hasMany = array(
'StudentFee' => array(
'className' => 'StudentFee',
'dependent' => true
)
);
}
class StudentFee extends AppModel {
public $name = 'StudentFee';
public $belongsTo = array(
'Student' => array(
'className' => 'Student',
'dependent' => true
)
);
}
请帮我保存 studenFee 的详细信息。我使用保存监护人和学生详细信息的 SaveAssociated 功能。