Topic awaiting preservation: One Project - want to set up on multiple databases - where do I start (Page 1 of 1) |
|
---|---|
Bipolar (III) Inmate From: you tell me |
posted 01-04-2009 06:56
Ok so our web application is doing pretty good - however we are interested in setting it up so that its spread over more than one database. The reason being is that since its a service based web application the database holds two kinds of information - one is basically configuration and utilitiy information that almost hardly changes unless we change it ourselves the other is user related information like contact information. We're thinking of having it set up so that we have one single database which contains all tables that are utility related for running the application. Users when they would sign up the would enter details of a database server or we could provide that for them and for each user who signs up they would have their own database which would contain all information that they'd enter themselves like for example our application has the following tables: |
Maniac (V) Mad Scientist with Finglongers From: Germany |
posted 01-04-2009 10:58
well, basically all you need to do is to split your database abstraction layer - either into multiple global objects (if that's what you've been using so far), or multiple different query functions (that each use the appropriate link). |
Bipolar (III) Inmate From: you tell me |
posted 01-04-2009 12:31
Database abstraction layer? Uh ok I'm lost now on teh terminology here but I might have worked on it but cant understand what it refers to? How would my queries actually look like then - I mean how would I be able to lets say do something like a JOIN on two tables from two different databases and stuff like that? |
Paranoid (IV) Inmate From: INFRONT OF MY PC |
posted 01-04-2009 13:50
quote: |
Maniac (V) Mad Scientist with Finglongers From: Germany |
posted 01-04-2009 13:58
Joining multiple databases within one connection shouldn't be a problem - you simply prefix the tables with the databasename (like db.table). |
Bipolar (III) Inmate From: you tell me |
posted 01-05-2009 08:04
OK I think I udnerstand that part for now I have a simple db class which has a few helper db functions the most basic is teh db->query() which takes a string SQL statement and executes it using a mysql_query() function call. code: class cAddress{ private db; function __construct(){ $this->db = new cDB(); } function addContact($oneContact) { //build sql query $sql = 'SQL build from $oneContact variable' $this->db->query($sql); } }
|
Maniac (V) Mad Scientist with Finglongers From: Germany |
posted 01-05-2009 15:04
I'd presume you either replace your new cDB() calls with a factory pattern (i.e. a function GetDBForCustomer() and getDBForSystem()) where appropriate. |
Bipolar (III) Inmate From: you tell me |
posted 01-06-2009 06:45
Hmmm is there any open source library that demonstrates this concept - I'm kinda low on time here and not much in the mood to redo everything from scratch. |