If you want pdo to operate two databases at the same time, can you only connect two pdo databases? this post is last written from sky94132003 to 2014-06-0617: 43: 02 edit because the main site is like a CMS, and there are articles, members, etc. but sometimes there are many different sub-stations (as a special topic) the content architecture of each sub-station is different, so you cannot use the same data table to operate two databases at the same time. do you have to connect two pdo databases?
This post was last edited by sky94132003 at 17:43:02 on
This is the case.
The main site is a CMS, with articles, members, etc.
But sometimes there will be a lot of different substations (as a special topic)
The content architecture of each sub-station is different, so the same data table cannot be used. in this case, each sub-station may have 7 ~ 8 databases
300 ~ will be used for 50 substations ~ More than 400 tables?
So I want to separate the database for processing.
$ Pdo = new PDO ('MySQL: host = localhost; dbname = cm', 'user', 'password ');
$ Pdo_zt15 = new PDO ('MySQL: host = localhost; dbname = zt15', 'user', 'password ');
At the same time, two operations are performed because the sub-station (subject) also needs to use the member information of the Master Station database.
I want to operate the database at the same time. Do I have to do this?
Or are there other methods?
------ Solution --------------------
If the two databases are on the same mysql server with the same user name and password, you can use the table name prefix database name: database name. table name during access.
------ Solution --------------------
Reference:
However
In the PDO topology
This example has been filled in: dbname = cms
$ Pdo = new PDO ('MySQL: host = localhost; dbname = cm', 'user', 'password ');
Can I use DB1.table1 again in SQL statement?
As long as it is a server with the same account and password, and the account has the permission to access two databases. You can.