Understanding of MVC
Abstract: This article focuses on the understanding of the MVC development mode in PHP development.
When a user triggers a command through a url, such as url = parameters (TP3.2) and article_add as a method, the parameters transmitted by the user through the url are processed. This is the control layer!
When the method passes through parameters such as db_blog, find the heap blog table in the database. Find the Username table in the blog through db_Username, which is the business layer. However, in MVC, the business layer and model layer are often merged.
The legendary model layer is actually adding, deleting, querying, and modifying databases.
2014-02-25
PS: MVC, M Refers to the Model layer, that is, the Model layer. The initial design is the data or information that the program needs to operate on, that is, write some common database-related operations in the model layer. For example, you can write a query on a database. However, it is not necessary to write in it. In actual development, it can be written in the control layer for convenience. As long as it can be effective for the database operation, the effect is the same. This does not mean that the model layer is redundant. You can encapsulate frequently used operations in it. For example, you can add UTF-8 to gbk operations for query queries.
V indicates the View layer. It mainly refers to the final result we send to the Web browser-such as the HTML generated by our script. When it comes to views, many people think of templates. The so-called templates are html pages prepared by others. You just need to embed the templates into our system. Generally, you only need to add a label to it, and the control layer throws the variable to the view layer. The URL resolution specification is set according to each system. The tag is used to parse the lost variables and display them.
C Refers to the controller of the control layer. The main business logic of a system is written in the control layer. Data is submitted to the control layer through the view layer. After the control layer processes (including processing, database operations, and interaction with the model layer), data can be displayed at the view layer, or update the database.
A simple example reference: http://www.jb51.net/article/60796.htm
6.5.21 sorting