As part of a university project I'm developing a web application in PHP and trying to follow MVC principles as much as possible. I'm not using an off-the-shelf framework because I want as much of the project to be my work as possible to help get a higher mark.
To delete an item (each item has an id, status, title, parent_id) from a database I go do the following process....
- User hits a delete button and is asked to confirm
- When clicking confirmed a "page" loads which calls the controller, initiates a model which is stored in the controller object
- A method in the model object is called to load the item from the database based on the ID in the URL
- I edit a status property in the model to mark the item as deleted
- I then save the model to the database which in effect deletes it.
I also want to delete all child items in the database of the item that has just been deleted. Where is the best place to do this? In the the controller? In a separate functions file? In a model file?
I'm pretty new to the whole MVC idea, so any help / advice is much appreciated.