Read PDO operate two databases at the same time, can only do two PDO connection?

Source: Internet
Author: User
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.


  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.