07-20-2023, 02:42 PM
Let's say I have a Model 'Retrieve.php' where I have a class named 'Retrieve' and it retrieves posts from a database. Then I have Controller in `Index.php` where I load that model, retrieve posts and pass it to view.
And now, I have one more page where I have to show those posts. Let's say `Sidebar.php` or something. And now again, I have to retrieve those posts. So, can I load 'Retrieve.php' once more, or I have to create one more model for `Sidebar.php` which extends 'Retrieve.php'? What is better practise?
And, in general, do I need for every controller create a new model in a good PHP MVC? If yes, probably Controller and Model should be named the same? Any more advices/comments?
Thank you.
And now, I have one more page where I have to show those posts. Let's say `Sidebar.php` or something. And now again, I have to retrieve those posts. So, can I load 'Retrieve.php' once more, or I have to create one more model for `Sidebar.php` which extends 'Retrieve.php'? What is better practise?
And, in general, do I need for every controller create a new model in a good PHP MVC? If yes, probably Controller and Model should be named the same? Any more advices/comments?
Thank you.