What is the problem between a control layer call model and a view layer call model?

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.