Using cake 2.x I have 3 tables (I've shortened the names for this example removing the plural/singular cakephp conventions):
- Main (has many Sub1)
- Sub1 (belongs to main, hasmany Sub2)
- Sub2 (belongs to sub1)
When I delete a category from Main, all of its dependent sub1/sub2 items are properly deleted using $this->Main->delete($id, true) call.
However I'm not sure how to delete an item from Sub1 and remove all it's sub2 properties. The controller needs to manipulate all three levels of the tables. I tried:
$this->loadModel('Sub1');
$res = $this->Sub1->delete($id, true);
But it is not picking up the model bindings to Sub2 and deleting them. What is the proper convention for doing this kind of thing in cake and/or what am I doing wrong?