ThinkPHP MVC development mechanism instance parsing, thinkphpmvc_PHP tutorial

Source: Internet
Author: User
ThinkPHP MVC development mechanism instance parsing, thinkphpmvc. ThinkPHP's MVC development mechanism instance parsing. thinkphpmvcThinkPHP is a widely used MVC development framework in China. This article explains ThinkPHP's MVC development mechanism in the form of examples. ThinkPHP MVC development mechanism instance parsing, thinkphpmvc

ThinkPHP is a widely used MVC development framework in China. This article explains ThinkPHP's MVC development mechanism in the form of examples. I believe it will give you some inspiration. The specific analysis is as follows:

I. Overview:

The MVC framework is parsed as follows:

M Model layer Model: Database operation class (operate tables through database operation class)

V View layer View:Template.

C Control layer controller:It is the control relationship between templates and models through controllers.

II. instance analysis:

1. ACTION controller:

Location D: \ www \ aoli \ Home \ Lib \ Action \ IndexAction. class. php

The code is as follows:

Public function test () // access path: http: // localhost/aoli/index. php/Index/test {$ Test = D ('test'); // instantiate Model // $ list = $ Test-> select (); $ list = $ Test-> query ("select * from test"); $ this-> assign ('list', $ list ); $ this-> assign ('title', 'Peng Yanjie '); $ this-> display ();} public function index () // index corresponds to index.html under aoli \ Tpl \ default \ index{$ this-> display ();}

2. MODEL:

Location D: \ www \ aoli \ Home \ Lib \ Model \ IndexModel. class. php

The code is as follows:

<? Phpclass TestModel extends Model {// corresponding to the table test in the database // you can add a class for operating the database table here}?>

3. VIEW:

Location D: \ www \ aoli \ Home \ Tpl \ default \ Index \ test.html

The code is as follows:

 

{$title}

{$vo.title} - {$vo.con}

If you are interested, you can debug and run the instances described in this article to deepen your understanding. I hope this article will help you learn ThinkPHP.


I am a newbie to several thinkphp Development examples and source code.

There are many download options on the official website. Www.thinkphp1.cn/case/index.html
 

Briefly describe the understanding of the MVC mode, and briefly describe how the MVC mode in ThinkPHP runs

The Model-View-Controller application structure is used to analyze the characteristics of distributed applications. This abstract structure can help split an application into several logical components, making programming easier.
The MVC structure provides a way to split objects by function (these objects are used to maintain and present data ), the goal is to minimize the coupling between objects. The MVC structure was originally designed to apply traditional input, processing, and output tasks to Graphical user interaction models. However, applying these concepts to the Web-based enterprise-level multi-layer applications is also very suitable.
In the MVC structure, the Model represents the data of the application and the business rule used to control access and modify the data ). A model is usually used as a software approximation of a processing process in the real world. when defining a model, a general simple modeling technology can be used.
When the model changes, it notifies the View and provides the ability to query the status of the model. It also provides the Controller with the ability to access the application functions encapsulated in the model.
A View is used to organize the content of a model. It obtains data from the model and specifies how the data is presented. When the model changes, data performance consistency is maintained. Inform the Controller as required ).
The Controller defines the behavior of an application. it is responsible for interpreting the user requirements from the view and ing these requirements into the corresponding behavior, which is implemented by the model. In a self-running GUI client, you may require some mouse clicks or menu selection operations. In a Web application, they may be expressed in some HTTP requests from the client GET or POST. The behaviors implemented by the model include processing the business and modifying the model status. Based on user requirements and model behavior results, the controller selects a view as the response to user requests. Generally, a set of related function sets correspond to a controller. Describes the relationship between model, view, and controller in an MVC application:
Java has STRUCTS and SPRING
Reference: zhidao.baidu.com/question/301083632.html

ThinkPHP is a widely used MVC development framework in China. This article explains ThinkPHP's MVC development mechanism in the form of examples. Phase...

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.