How to implement multi-table query in thinkPHP framework

不言
Release: 2023-04-01 08:14:01
Original
5298 people have browsed it

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;
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!