0

我正在使用 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.
4

2 回答 2

1

尝试将$cascade第二个参数设置为true。因此,所有相关记录也将被删除,如果dependent在您的模型中也设置为 true。

依赖 级联

于 2012-04-10T10:17:22.487 回答
0

尝试这个

$this->TutorialDiscussion->deleteAll($condition,false);
于 2012-07-12T12:47:55.003 回答