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