search

Home  >  Q&A  >  body text

How to perform multi-table query operations in thinkphp5.1?

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.

鸿运达鸿运达2184 days ago1760

reply all(4)I'll reply

  • 胤彬-

    胤彬-2018-11-23 14:01:17

    Just use model association

    reply
    0
  • 杨云雷

    杨云雷2018-11-22 08:23:19

    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

    reply
    0
  • Summer

    Summer2018-11-21 16:55:25

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

    reply
    0
  • 鸿运达

    鸿运达2018-11-21 12:56:44

    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.

    reply
    1
  • Cancelreply