The difference between D() and M() methods:
The main difference between D and M is that
M method does not need to create a model class file, M method The model class will not be read, so automatic verification is invalid by default, but it can be achieved through dynamic assignment
and the D method must create a model class.
We can use the following two methods to create a mapping object of a data table
The first one: $Test = D('Test')
The second one: $Test = new Model('Test')
Although both can perform select, insert, delete, and udpate operations on data, there is a big difference in
data verification.
Use the first In this way, a model will have a data check function. If the title is not filled in, it will prompt "Please enter the title" (this is an automatic verification function provided by TP, of course, the verification conditions also need to be defined in the corresponding model);
If you use the second method, it will be gone...
There is another difference: when $trueTableName is used, $test=d('test') must be used, which means that the test table is queried ,
If $test=m('test') is used, it means that the data side of the query is think_test.
thinkphp2.0 version test has the above problems