This article mainly introduces the method of thinkPHP framework to implement multi-table query, and briefly analyzes the usage and precautions of thinkPHP where in multi-table query in the form of examples. Friends in need can refer to it
The example in this article describes how the thinkPHP framework implements multi-table query. Share it with everyone for your reference, the details are as follows:
We can connect the two tables to query the data together. I now have two tables, one is the feedback table and the member table, as shown in the figure:
General directory:
## Upper code:$where = array(); $where['meiyepin_feedback.member_id'] = "1"; $Model = M('feedback'); $a = $Model ->join('meiyepin_member ON meiyepin_feedback.member_id = meiyepin_member.member_id') ->where($where) ->select(); var_dump($a);exit;
Usage of where:
If the field you want to query only exists in one table, then it is the same as the usual where The usage is the same, but if your query field exists in two tables at the same time, then you need to add the table name, as shown in the above code
. The above is the entire content of this article. I hope it will be helpful to everyone's learning. For help, please pay attention to the PHP Chinese website for more related content! Related recommendations:About the usage analysis of dynamic configuration of thinkPHP framework
The implementation methods of three PHP recursive functions and Realize the accumulation of numbers
The above is the detailed content of How to implement multi-table query in thinkPHP framework. For more information, please follow other related articles on the PHP Chinese website!