是否有更有效的方法通过id删除多个实体
$data = $this->request->data ['missing_lexicon_id'];
foreach ( $data as $id ) {
$missingLexicon = $this->MissingLexicons->get ( $id );
$this->MissingLexicons->delete ( $missingLexicon )
}
Run Code Online (Sandbox Code Playgroud)
这应该工作
$this->MissingLexicons->deleteAll(['MissingLexicons.column IN' => $keys]);
Run Code Online (Sandbox Code Playgroud)
其中$ keys是一个包含要删除的ID的数组.
| 归档时间: |
|
| 查看次数: |
7180 次 |
| 最近记录: |