PHP/MySQL - Working with two databases, one shared and one local to an instance of application

Posted by Extrakun on Stack Overflow See other posts from Stack Overflow or by Extrakun
Published on 2010-04-29T12:31:24Z Indexed on 2010/04/30 8:17 UTC
Read the original article Hit count: 286

The situation: Using a off-the-shelf PHP application, I have to add in a new module for extra functionality. Today, it is made known that eventually four different instances of the application are to be deployed, but the data from the new functionality is to be shared among those 4 instances. Each instance should still have their own database for users, content and etc.

So the data for the new functionality goes into a 'shared' database. The data for the application (user login, content, uploads) go into a 'local' database

To make things more complex, the new module I am writing will fetch data from the local DB and the shared DB at the same time.

A re-write of the base application will take too long. I only have control over the new module which I am writing.

The ideal solution: Is there a way to encapsulate 2 databases into one name using MySQL? I do not wish to switch DB connections or specifically name the DB to query from inside my SQL statements.

The application uses a DB wrapper, so I am able to change it somehow so I can invisibly attempt to read/write to two different DB.

What is the best way to handle this problem?

© Stack Overflow or respective owner

Related posts about php5

Related posts about mysql