How to Connect two databases on two different servers using php

后端 未结 2 1510
日久生厌
日久生厌 2021-01-29 04:37

In MySQL, I have two different databases -- let\'s call them A and B.

Database A resides on server server1, while database B resides on server server2.

Both serv

相关标签:
2条回答
  • 2021-01-29 05:03

    The only way I can think of, is by opening 2 separate connections (i.e. instantiate 2 PDO objects) with all the different parameters, use 2 queries to query all the data you need into PHP, and then work with that on PHP.

    0 讨论(0)
  • 2021-01-29 05:20

    You can make two separate MySQL connections in PHP, do two queries to the two tables, and then work with the results in PHP.

    Another option, since the servers are physically close, is to setup the one or both servers to replicate the needed database/tables to each other. You can look here for more on MySQL replication: http://dev.mysql.com/doc/refman/5.6/en/replication.html

    0 讨论(0)
提交回复
热议问题