english_bt — 2014-06-10T07:16:17-04:00 — #1
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
ahundiak — 2014-06-10T10:05:25-04:00 — #2
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.
english_bt — 2014-06-10T20:53:40-04:00 — #3
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