有没有更有效的方式通过 id 删除多个实体
$data = $this->request->data ['missing_lexicon_id'];
foreach ( $data as $id ) {
$missingLexicon = $this->MissingLexicons->get ( $id );
$this->MissingLexicons->delete ( $missingLexicon )
}
请您参考如下方法:
这应该工作
$this->MissingLexicons->deleteAll(['MissingLexicons.column IN' => $keys]);
其中 $keys 是一个包含要删除的 id 的数组。