The MVC pattern (three-tier architecture model) (Model-view-controller) is a software architecture model in software engineering that divides software systems into three basic parts: model, view, and controller
<INM src= "./images/1.gif"/>
The first one "." Represents the current path
Use the MVC development model to complete employee additions, modifications, deletions, displays, queries
Draw the program frame diagram, clear thinking Design file number (try, model, controller)
I. Model
Model is used to cure data. Encapsulates data that is related to business logic and how to handle data. The model does not care how the business is implemented, it only cares about how the data is stored. For example, how the scripting language interacts with database data, and the encapsulated SQL statement. The main use of PHP, ASP, JSP and other server scripting language to achieve. Layer 1th: Data access Abstraction Layer
Abstract code for database access such as metabase, Pear:db, PDO, and ADODB are written in code within the model layer. Methods for adding, deleting, modifying, and so on, are all encapsulated into a single class of methods.
2nd Floor: DAO
The DAO data Access Objects object is a concept in Java development. The plain thing is to encapsulate those SQL statements into a class that encapsulates different SQL statements into a single method. Then the SQL language is used to instantiate the DAO class as an object, and the use of the SQL statement is accomplished by invoking the method in the object. Two. Controllers (Controller)
The controller acts as an organizational function between different levels to control the flow of the application. The controller layer often put some business logic aspects of code, some business aspects of the logical events encapsulated into a class of methods, and the method must invoke the 2nd layer of the DAO object, to complete the operation of business logic. It is also implemented using server scripting languages such as PHP, ASP, and JSP. Layer 3rd: Server
The server layer is primarily a grooming of business logic. Specific such as landing, registration, add articles such as basic function events are divided into different classes, not the same method. Create a class called "User", the class write various methods, registration, login, account password matching and so on three. Views (view)
The view layer is used to display data, design, and output Web pages. The main use of HTML, CSS, JS language, and a little bit of server scripting language.
Level 4th: Controller
The controller layer, although called the controllers, does not really matter what the code and control are. The inside is some server and user data interaction, directly call the class in the server layer, and instantiate it, output the required data. In fact, the server and the user-side data interaction. Cough, PHP is generally used to implement this layer. and call the display code in the view layer below. 5th floor: View
The view layer in the main is the HTML, CSS, JS these code, in addition to note, want the server script language output data? Written in view, controller cannot output
Advantages of developing a Web site with MVC:
There are many advantages, we can check online.
1. The code is concise and tidy. Easy to modify
2. Co-development is convenient, Dber is responsible for writing model code, the background programmer is responsible for writing controller code, front-end engineers are responsible for writing the view layer
3. Easy Code Maintenance
MVC pattern improves site structure