I'm trying to understand MVC thing and so far I know that it's used to separate business logic from the view logic (something as HTML and CSS), but I fail at point when I need to organize my files.
Lets say that I have 3 files:
So looking at my example:
Right?
Wrong, Actually you are mixing Model and Controller in process.php.
form.php and display.php are only interacting with user, they are acting as views.
process.php is acting as both Controller and Model
You should separate the Controller and Model. You can create a separte model.php and do the database stuff there. So if in future you need to change your database stuff. you dont need to touch process.php. Controller and Model will also be separated from each other
I'd say more like
There is no actual model. If you have a data structure to represent the data in someDataClass.php, that would be a model.
What you want is to separate the UI (view), the data processing(controller) and the data definition(model).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With