I've read several articles, watched videos and read questions on here, but the more I read and learn about MVC - including MVCS or MVP in addition.. to make it even worse - the broader the pattern seems, so I apologize if the question is broad or long it is just because I really want to figure it out and understand its combination.
First:
Is it the Model which writes, renders or updates data on the View, or it's the Controller, I've seen places where the developer uses the first approach, while the latter is used more - which makes more sense to me because of the view-controller pair and since the Model better be separated, or this what I think - but even with a simple block diagram, this varies a lot.
Second:
Having these generic logic codes for the two examples:
Example 1:
// UserModel:
function getUsersDetails(id= false){
if(id){
// Fetch that specific user details with the id provided
}else{
// Fetch all users details
}
}
// UserController:
result = UserModel->getUsersDetails(id) // id is optional depending on the view
Example2:
// UserModel:
function getAllUsersDetails(){
// Fetch all users details
}
function getUserDetails(id){
// Fetch that specific user details
}
//UserController:
//for ONE user details View
result = UserModel->getUserDetails(id)
//for a View of ALL users
result = UserModel->getAllUsersDetails()
Which one of the above examples is the better approach, personally I guess it is the Example2 because of the "no logic in the Model" rule, but if so, this confuses me even more when some people say "No SQL in the Model, instead put it in repositories or a Store". If the Model should not contain logic, and better not contain SQL , what would it be consist of then, just empty methods calling functions from the repositories? wouldn't this make it unnecessary and add more complexity to the whole design.
I apologize if the post has many questions or it is broad and Thanks in Advance