我正在使用 cakephp 2.0。使用 deleteAll 函数。我的记录没有从数据库中删除,我没有收到任何错误。
public function admin_deleteTutorial($tutorial_id = null){
if($tutorial_id > 0){
// $this->Tutorial->delete($tutorial_id);
$condition = array('TutorialDiscussion.tutorial_id' => $tutorial_id );
$this->TutorialDiscussion->deleteAll($condition);
$this->Session->write('message','Tutorial details deleted successfully.');
$this->redirect('/admin/tutorials/index/');
}
}
** Is it required to first find out list of all id's from TutorialDiscussion having tutoril id this $tutorial. or it will delete all itself.** Though records are deleted from TUtorials so I have commented that.