Welcome Guest, Not a member yet? Register   Sign In
Dynamically set up multiple array concurrent connections
#1

[eluser]bossbs[/eluser]
Hi guys,
I'm back for a quick hint on databases again..

I'll start explaining you my db web site structure and then comes the question:
in my website, I create a new DB with some information for every new registered user (we'll call it UserDB_01 for user1, ecc) and I store some other data like username, email and so on in another database (we'll call it CommonDB).

The problem is this:
once user1 logs in I verify that his credentials are valid against CommonDB and everithing works fine;
at this point "I have to switch" to UserDB_01 for other operations but I don't know how to solve this "switch".
Consider that once user2 logs in, I'll verify his credentials against CommonDB, but this time I'll have to switch on UserDB_02 for secondary operations, and so on for every other user.
In this way we can say that each user needs to connect with two databases: CommonDB and UserDB_XX.

I know that in the database.php file I can create different "database groups" and I'm trying to use them, but due to the fact the users may grow up quickly I want to have only 2 groups:
default -> which stores CommonDB data connection (for authentication)

AND

UserDbGroup -> which stores UserDB_XX generic data, and where I have to set up only the right database name (bold line below) to establish the right connection:

$db['UserDbGroup ']['hostname'] = Q_SQL_SERVER;
$db['UserDbGroup ']['username'] = Q_SQL_USER;
$db['UserDbGroup ']['password'] = Q_SQL_PASS;
$db['UserDbGroup ']['database'] = "";
$db['UserDbGroup ']['dbdriver'] = "mysql";
$db['UserDbGroup ']['dbprefix'] = "";
$db['UserDbGroup ']['pconnect'] = TRUE;

Ok,
is it clear? I hope but I don't think so..
anyway, suggestions and eventually clarifying questions are welcome!

PS:
please don't say me that this kind of architecture with multiple databases is wrong, I cant change it..
Thanks,

Pietro


Messages In This Thread
Dynamically set up multiple array concurrent connections - by El Forum - 03-21-2011, 12:12 PM



Theme © iAndrew 2016 - Forum software by © MyBB