How to perform multi-table query operations in thinkphp5.1?
鸿运达
鸿运达 2018-11-21 12:30:04
0
4
1795

There are two data tables, one is alipay and the other is wxpay. The fields of the two tables are the same.

When a user queries recharge records, how can he use the model or DB class to query the two databases at the same time and get one result?

-------------------------------------------------- --------------------------

The content cannot be in pure English, and the number of words must be at least 100 words. The content cannot be in pure English. , and the content must be at least 100 words in pure English, and the content must be at least 100 words in pure English, and the content must be at least 100 words in pure English, and the content must be at least 100 words in pure English, and the content must be at least 100 words in pure English The above content cannot be pure English, and the number of words must be at least 100 words. The content cannot be pure English, and the number of words must be at least 100 words. The content cannot be pure English, and the number of words must be at least 100 words.

鸿运达
鸿运达

reply all(4)
胤彬-

Just use model association

杨云雷

Two data tables are still two databases. If there are two data tables, just check it directly through the view. It is in the tp5 document. If there are two databases, one of them needs to use Db::connect("connection parameters")->query("query statement"), or directly use native syntax to query

Summer

If you do this with a large amount of data, the performance will be poor, just use jion to query the table

鸿运达

The problem is solved, just convert the query results into array format, and then merge the two arrays.

I have learned relatively little about MYSQL and have not used joint table queries.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template