Can I only connect two pdo databases when I read pdo and operate them at the same time?

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


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.