Hi guys I am trying to learn MVC and correct usage of interfaces and repositories. Would this be a good start? Is it a good design?
What is the next step to improve this? Thank you.
Many thanks fellows
Having the controller access the database via a repository is a good thing.
Your 'members_model' seems superfluous. The repository should be the one to access the database. No need for another layer.
// In your controller
$members = $this->memberRepository->finadAll();
foreach $members as $member) ...
$memberId = 42;
$member = $this->memberRepository->find($memberId);
You might be confusing your members_model with the domain model. The domain model (if you have one) would consist of the $member entity with no database specific code.
If you have not already, you might take a look at Doctrine 2.
1 - I have been trying to understand the layers but haven't been able to yet! So when you say domain model I don't really follow. Would you please explain that via my graph?
2 - The other thing that I wonder is what is the best ways to handle errors. Everything from sql failure to failure in controller, repository, interface or the model. Do you mind showing me where is the best place to do that?
3 - By looking at this, how much do you think I understand about OOP? Is it a good idea to move to a freamework? Or not just yet? It sounds like an ocean, not sure where I am ni the level of progress lol
This topic is now closed. New replies are no longer allowed.