thinkphp Model Connection database query Ajax

Source: Internet
Author: User

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

Related Article

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.