The table method of ThinkPHP CURD

Source: Internet
Author: User

The table method of the ThinkPHP CURD method is also one of the coherent operation methods of the model class.Data Tables Used for specified operations.

The usage is as follows:

Generally, the system can automatically identify the corresponding data table when operating the model. Therefore, the table method is generally used:

1. Data Tables for switchover operations;
2. Operate on multiple tables;

For example:

$ Model-> table ('Think _ user')-> where ('status> 1')-> select ();

You can also specify the database in the table method, for example:

$ Model-> table ('db _ name. think_user ')-> where ('status> 1')-> select ();

Note that the table method does not change the database connection. Therefore, make sure that the currently connected user has the permission to operate the corresponding database and data table.

After the data table is switched, the system automatically obtains the field cache information of the switched data table.

To operate multiple tables, use the following method:

$ Model-> field ('user. name, role. title ')-> table ('Think _ user, think_role role')-> limit (10)-> select ();

To avoid conflict with mysql keywords, we recommend that you use arrays, for example:

$ Model-> field ('user. name, role. title ')-> table (array ('Think _ user' => 'user', 'Think _ role' => 'role')-> limit (10) -> select ();

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: 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.