1. Connect to the database
In the template configuration file, write
2. Create model models for the Home and Admin to work together
3. Ways to instantiate a model
The first type:
.
Second type: M () method
Third type: D () method
The difference between the M () method and the D () method:
after tp3.2 ,m() and D () are the same, in the Previous version of 3.2 m () similar to the new Model (), D (' goods) is similar to the new Goodsmodel (), both the M method and the D method are used to instantiate a model class, the M method is used to instantiate an underlying model class efficiently, and the D method is used to instantiate a user-defined model class.
M () method for simple curd operation of data tables without complex business logic
But to use the business logic inside the model class, use the D () method
Extension
Data processing routine is to delete and change curd
Add: C create corresponds to thinkphp is $n->add ()
Delete: D Delete corresponds to thinkphp is $n->delete ()
Change: U update corresponds to thinkphp is $n->save ()
Check: R read corresponds to thinkphp is $n->select ()
)
thinkphp Model Connection database query Ajax