Welcome Guest, Not a member yet? Register   Sign In
A unique multiple database implementation
#1

[eluser]textnotspeech[/eluser]
I need some advice on the best way to do the following:

I have an application that uses multiple databases. The main database is basically a user database that stores some info about clients (permissions etc.) including the connection settings for the client's site database. Other than authentication of users and user info, I have a basic blog table that holds recent news (for the dashboard of the app). In every other part of the app, the database I wish to connect to is the client DB. I've been handling this by loading the models (client DB) with secure session info passed dynamically with config like so:

Code:
// Getting the specifics from session data
$config['hostname'] = "client.db.host";
$config['username'] = "client_db_username";
$config['password'] = "client_db_password";
$config['database'] = "client_database_name";
$config['dbdriver'] = "mysql";
$config['dbprefix'] = "";
$config['pconnect'] = FALSE;
$config['db_debug'] = TRUE;

$this->load->model('Model_name', '', $config);

This is the method outlined in the userguide for loading models with dynamic config settings. I'm not sure if I can pre-config these databases in the config file because the settings aren't available to the app until the user logs in. I'm sure there are some security issues using sessions to store this info but I'm not really sure how to go about doing this.

Basically, my app is a CMS that manages client site databases from my site, allowing me to have one app to manage multiple sites. This detached architecture allows me to keep the client's site separate from the CMS hosting server and keeps me from having to actually host my client's database on my hosting account. It also gives me one code base to update for upgrades, fixes, and changes. I've been having problems lately with the above method of connecting to the models because it keeps connecting to my database and not the clients (my mouse went berserk on me and was randomly double-clicking on single click and I think I may have screwed something during ftp). After countless svn checkouts and re-uploading I've not been able to restore my app to working order and I don't know if it's a bug or if I'm retarded. I'm trying to re-build my app piece by piece from a fresh CI install and I just thought I might ask for some insight into how I may implement this differently while I'm at it.

This should be interesting.




Theme © iAndrew 2016 - Forum software by © MyBB