Sankalp
Sankalp

Reputation: 17

Issue with deleteAll in cakephp..

I am usign cakephp 2.0. Using the deleteAll function. I am not getting any sort of error by my records are not deleted from DB..

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.

Upvotes: 0

Views: 8111

Answers (2)

apurav gaur
apurav gaur

Reputation: 342

try this

$this->TutorialDiscussion->deleteAll($condition,false);

Upvotes: 0

Jonas Millan
Jonas Millan

Reputation: 55

Try to set $cascade as the second parameter to true. So all related records are also deleted, if dependent is also set to true in your model.

dependent cascade

Upvotes: 1

Related Questions