Handling recursive deletion in Yii

Comparing #5 with #7

Content

As a lead developer at Mutable Labs II [www.jamesbarnsley.com](http://www.jamesbarnsley.com "www.jamesbarnsley.com") was tasked to find a way to do recursive deletion in Yii. As I asked other developers and looked around the internet the usual answers all came up, use a plugin or use cascade delete at the DB level, but I did not want to do either of these.

So I came up with my own solution which I found to be simple and effective. It all starts off by adding a function to your global model, if you do not have one of these then create one. Create a model that extends active record and then make sure your other models extend the global model. This creates a nice place to put global model functions which can be used by any model in your application.

Add this function to the global model ...
[...]