I have implemented comments functionality in one of my sites using CakePHP and it’s find('threaded') feature.
When I delete a parent comment, I want all it’s child comments (n-level children) to get deleted too, using CakePHP model’s delete method.
Say, following is the case:
id = 5 parent_id = 0;
id = 6 parent_id = 5;
id = 7 parent_id = 5;
id = 8 parent_id = 7;
And I do:
$this->Comment->id = 5;
$this->Comment->delete();
I want records with comment id = 5, 6, 7, 8 to get deleted.
Please advice.
Thanks
I haven’t tested the following code, but I would do something like this: