我是蛋糕 PHP 新手,我有一些问题
共有三种模式:Guardian、Student 和 StudentFee。
关系如下所示:Guardian hasMany Student,Student hasMany StudentFee,StudentFee 属于 Guardian,Student。
我的问题是除了插入学生和监护人详细信息外,没有插入 StudentFee 详细信息。
我的模型就像
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(
'Guardian' => array(
'className' => 'Guardian',
'dependent' => true
),
'Student' => array(
'className' => 'Student',
'dependent' => true
)
);
}
在我的控制器中,我使用了 saveAssociated() 如下代码
$this->Guardian->set($this->request->data);
$this->Guardian->saveAssociated($this->Guardian->data, array('validate' => false));
请帮助解决此问题,在此先感谢。