CakePHP 3.2级联删除

时间:2016-04-01 04:47:07

标签: php cakephp cakephp-3.0

我刚刚将CakePHP升级到版本3.2。但是,我遇到了一个问题。

我想从Schoolassessments表中对单个Schoolassessments记录进行级联删除。在Schoolassessments表中,我将my(id和student_id)设置为数据库中的PK。

$selectedAssessment = $Schoolassessments->find()->where(['id' => $assessmentId, $this->typeField =>'2AAA-XXXX'])->first();
$Schoolassessments->delete($selectedAssessment);

这是Schoolassessments表。

$this->hasMany('SchoolassessmentsScores', [ 
    'className' =>'SchoolassessmentsScores', 
    'conditions' => [
        'Schoolassessments.id = SchoolassessmentsScores.assessment_id'
    ],
    'foreignKey' => false,
    'dependent' => true,
    'joinType'  => 'INNER'
]);

这是SchoolassessmentsScores表。

$this->belongsTo('Schoolassessments', [ 
    'className' =>'Schoolassessments', 
    'conditions' => [
        'Schoolassessments.id = SchoolassessmentsScores.assessment_id'
    ],
    'foreignKey' => false,
    'joinType'  => 'INNER'
]);

Schoolassessments记录被删除后。还应删除SchoolassessmentsScores相关记录。

但是,debugkit显示以下错误。

Warning (2): array_combine() [function.array-combine]: Both parameters should have an equal number of elements [CORE/src/ORM/Association/DependentDeleteTrait.php, line 44]
Warning (2): array_merge() [function.array-merge]: Argument #1 is not an array [CORE/src/ORM/Association/DependentDeleteTrait.php, line 53]

有人可以提供建议吗?

0 个答案:

没有答案