Parse the differences between M () and D () methods in thinkphp. The difference between D () and M () methods: the difference between D and M is that M methods do not need to create model class files, and M methods do not read model classes, therefore, automatic verification is invalid by default,
Differences between D () and M () methods:
The main difference between D and M is that
The M method does not need to create a model class file, and the M method does not read the model class. by default, automatic verification is invalid, but it can be implemented through dynamic assignment.
The D method must have a model class.
We can use the following two methods to create a data table ing object
First: $ Test = D ('test ')
Type 2: $ Test = new Model ('test ')
Both of them can perform select, insert, delete, and udpate operations on data.
There are big differences in data verification,
In the first method, the data check function is provided for a model instance. if the title is not entered, the system prompts "enter the title" (this is an automatic verification function provided by tp, of course, you also need to define the verification conditions in the corresponding model );
If the second method is used, there will be no ·····
Another difference is that after $ trueTableName is used, $ test = d ('test') must be used to query the test table,
If $ test = m ('test') is used, the queried data edge is think_test.
Thinkphp2.0 has such problems during the test.
The difference between http://www.bkjia.com/PHPjc/327757.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/327757.htmlTechArticleD () and M () methods: the difference between D and M is that M methods do not need to create model class files, M methods do not read model classes, so automatic verification is invalid by default, but it can be...