In a frame, I'm going to be in the view layer
OutputData out:
First, in the controller layer, all the data are assembled, the call model call model, and then the view layer template rendering, do not need to read the database, directly with the PHP function output is good.
Second, in the controller layer, simply put the necessary data processing, and then the view layer template rendering, according to the situation and then the database read operations;
Which of these two cases is better?
----------------------Supplement----------------------
My point of view: I think it is irrelevant, because in a controller method introduced a model in, is to say that a file is loaded in, and then in this method to read the data, and finally introduced template file in, then I am in this template file to read the database is also OK, But the former increases the readability and simplicity of the template code. In practical sense there is no big difference ah, do not know this is not the case?
----------------------Supplement----------------------
Know the characteristics of MVC, but see the predecessors have directly in the template to do database query operations, so only to produce such doubts, ask for doubts ~
Reply content:
In a frame, I'm going to output the data in the view layer:
First, in the controller layer, all the data are assembled, the call model call model, and then the view layer template rendering, do not need to read the database, directly with the PHP function output is good.
Second, in the controller layer, simply put the necessary data processing, and then the view layer template rendering, according to the situation and then the database read operations;
Which of these two cases is better?
----------------------Supplement----------------------
My point of view: I think it is irrelevant, because in a controller method introduced a model in, is to say that a file is loaded in, and then in this method to read the data, and finally introduced template file in, then I am in this template file to read the database is also OK, But the former increases the readability and simplicity of the template code. In practical sense there is no big difference ah, do not know this is not the case?
----------------------Supplement----------------------
Know the characteristics of MVC, but see the predecessors have directly in the template to do database query operations, so only to produce such doubts, ask for doubts ~
The first, single duty
Just started to write code, I want to save effort to write database query in the template, a method to solve all problems. It was not until the project ran for two months that the energy savings of the growing block of code would be doubled at this time, and the farther back the project would be, the more it would pay.
Now I'm using第一种
How to say, in fact, each has its own good,
Of course, whether from the specification, or from the development of the project, we recommend the use of the first.
If it is a small project developed by individuals, and there are not too many functions and later extensions, it is quicker to use the second method. Always use, always take
First kind of good! The first one also points to the business logic on M or c. This also varies from person to person.