In a framework, I want to output data at the View layer: first, in the controller layer, all the data is assembled and the call model of the call model is called, then, when rendering the View layer template, you don't need to read the database any more, just use the php function to output it. Second, in the controller layer,... a framework, I want
OutputData output:
First, in the controller layer, all the data is assembled. the call model of the call model is called. when the view layer template is rendered, no database is required.ReadDirectly use the php function output.
Second, on the controller layer, simply process the necessary data, and then read the database as needed when rendering the View layer template;
Which of the two situations is better?
---------------------- Supplement ----------------------
My point of view: I think it doesn't matter, because a model is introduced into a controller method, which means that a file is loaded in, then, read the data in this method, and then introduce the template file. then, I can read the database in this template file, but the former adds the template code.ReadabilityAndSimplicity. Actually, there is no big difference. I don't know if this is the case?
---------------------- Supplement ----------------------
I know the characteristics of MVC, but I can see that some of my predecessors directly made a database in the template.QueryOperation ~
Reply content:
In a framework, I wantOutputData output:
First, in the controller layer, all the data is assembled. the call model of the call model is called. when the view layer template is rendered, no database is required.ReadDirectly use the php function output.
Second, on the controller layer, simply process the necessary data, and then read the database as needed when rendering the View layer template;
Which of the two situations is better?
---------------------- Supplement ----------------------
My point of view: I think it doesn't matter, because a model is introduced into a controller method, which means that a file is loaded in, then, read the data in this method, and then introduce the template file. then, I can read the database in this template file, but the former adds the template code.ReadabilityAndSimplicity. Actually, there is no big difference. I don't know if this is the case?
---------------------- Supplement ----------------------
I know the characteristics of MVC, but I can see that some of my predecessors directly made a database in the template.QueryOperation ~
First, single responsibility
When I first started writing code, I wrote all the database queries to the template to solve all the problems. After the project has been running for a month or two, the effort saved in the early stage of the increasingly large code block will be doubled at this time, and the more time the project expands, the more time it will be paid.
Now I useFirst
In fact, each has its own advantages,
Of course, we recommend that you use the first one in terms of specifications or project development.
If it is a small project developed by a person, and there are not too many functions and later extensions, the second method is faster. Use at any time, take at any time
First! The first is to put the business logic in M or C. This varies from person to person.