Want PDO to operate two databases at the same time, can only do two PDO connection?
This post was last edited by sky94132003 on 2014-06-06 17:43:02
Because this is the case.
The main station is a CMS, there are articles, members and so on
But sometimes there are a lot of different stations (as a topic bar)
the content architecture of each sub-station is not the same, so it cannot be done with the same data table, it is possible to have 7~8 database per station
50 sub-stations, you have to use the 300~400 more than one table?
That's why we want to separate database processing
$pdo = new PDO (' Mysql:host=localhost;dbname=cms ', ' user ', ' password ');
$pdo _zt15 = new PDO (' mysql:host=localhost;dbname=zt15 ', ' user ', ' password ');
At the same time, the operation of two, because the sub-station (problem) also need to use the master database of the member information
I want to operate the database at the same time, can I do this?
Or is there another way?
------Solution--------------------
If the two libraries are on the same MySQL server, and the user name and password are the same, the library name can be prefixed to the table name at the time of Access: library name. Table Name
------Solution--------------------
Reference:
but
In the PDO connection
has already filled in this: dbname=cms
$pdo = new PDO (' Mysql:host=localhost;dbname=cms ', ' user ', ' password ');
Is it possible to use db1.table1 in a SQL sentence?
As long as the same server, the same account password, and the account has access to two libraries permissions. You can do it.