ThinkPHP-4-Study notes (2015.4.12)

Source: Internet
Author: User

Thinkphp D method

The D method is used to instantiate a custom model class, is an encapsulation of the model class instantiation by the thinkphp framework, and implements a singleton pattern that supports cross-project and group calls in the following format:
D (' [Project://][Group/] model ', ' model layer name ')
The return value of the method is the instantiated model object.

references : thinkphp function: D method http://www.thinkphp.cn/info/122.html

thinkphp Custom Template Labels

references : thinkphp Customizing template tags in detail http://w3note.com/web/124.html

thinkphp model

The role of model classes In most cases is to manipulate the data table, if you follow the system specification to name the model class, in most cases it is possible to automatically correspond to the data table .

===========================

Model classes are usually \think\model classes that inherit the system, and the schema method of the class has three parameters, namely:

Model ([' model name '],[' data table prefix '],[' database connection information ']);

Three parameters are optional, and in most cases we don't need to pass in any parameters to instantiate them.

Parameters Description
Model name The name of the model is combined with the data table prefix to automatically identify the data table name
Data table prefixes The current data table prefix and model name are used together to automatically identify the data table name
Database connection Information Database connection information for the current data table if not, gets the

===========================

M method

When the D method instantiates a model class, it is usually instantiated with a specific model class, and if you are simply curd the data table, using the M method instantiation, the performance will be higher because you do not need to load the specific model class.

reference : Model instantiation Http://document.thinkphp.cn/manual_3_2.html#model_instance

ThinkPHP-4-Study notes (2015.4.12)

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.