ThinkPHPCURD method-table method-PHP Tutorial

Source: Internet
Author: User
The table method of ThinkPHPCURD is described in detail. The table method of the ThinkPHPCURD method is also one of the coherent operation methods of the model class. this method is mainly used to specify the data table for the operation. The specific usage is as follows: Generally, the table method of the ThinkPHP CURD method of the operation model also belongs to 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 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();

The table method of the http://www.bkjia.com/PHPjc/825323.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/825323.htmlTechArticleThinkPHP CURD method is also one of the coherent operation methods of the model class, this method is mainly used to specify the data table of the operation. The specific usage is as follows: Generally, the operation model...

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.