Answer the question
In order to leave comments, you need to log in
Do I need to pass and process $_POST for the model?
Hello!
Since I recently started switching from a procedural to an OOP, I’m interested in the following moment: well, in the procedural we send $ _POST from the page with the form to a separate handler file and there we already have a reception, validation, writing to the database and a redirect, for example, back to form page.
But it's not quite clear how to do it CORRECTLY in oop?
Accept, validate in the controller, and then send the processed data to the model method for writing to the database?
Or ONLY accept and validate, and if successful, simply write data to the $_POST database in the model without transferring them from the controller to the model, because $_POST is superglobal?
Thank you.
Answer the question
In order to leave comments, you need to log in
It seems to me that you are confusing the concepts of oop and mvc. Well, in general, after the theory, try some kind of framework for example laravel, where the request is received by the router, sends it to the controller, and the controller calls the model that writes to the database
You accept a post in the controller, validate and pull the function of writing to the database from the model, indicating in the arguments what you are changing and that's it
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question