MVC, mvc framework. MVC is not a technology, but an idea that separates website user operations from background user operations (including database operations. Background MVC and mvc framework
MVC
It is either a technology or an idea that separates website user operations from background user operations (including database operations.
Php in the background is always called by user behavior. you must set an operation Portal for user behavior,
Operation entry: The essence is to use a URL (only one privlege. php? Action = value, goods. php? Action = value)
Background:
Parse the URL to get the URL and judge it according to the action ==> C in MVC
Operate the database according to different actions (actions) and obtain data => M in MVC
Use include to introduce an html file (Template) for echo information to the user ==> V in MVC
M: (module) the model is mainly used to operate the corresponding data tables (the table class goods. class. php, category. class. php, and user. class. php)
V :( view) view is the html document used to hold php echo data
C :( controller) the controller is mainly used to process business logic and control the trend of program processes.
Image analogy:
The user is the company's big boss
C (privilege. php, goods. php, index. php)
When a user sends a command, the middle-level company receives the command (one command can be divided into multiple steps: 1. reading data is a step; 2. returning data to the user ), company middle-level school Younger Brother 1 (user. class. php, goods. class. php) to read the data, younger brother 1 returns the data to the middle-level companies, the middle-level companies then hand over the data to younger brother 2, and younger brother 2 displays the data.
Why should user. class. php and goods. class. php inherit the DB class.
There are only four methods to operate the database. This operation application shows different transactions in different modules. Therefore, the business of each module cannot be encapsulated in the DB class, and the model class can be used to encapsulate different services of the same website module.
Users operate on "unexpected" behaviors of programmers. Users can only click the button or A link, and the href of A link is designed by programmers.
MVC diagram:
Expansion:
MVC is not a technology, but an idea that separates website user operations from background user operations (including database operations. Background...