Welcome Guest, Not a member yet? Register   Sign In
Multiple systems/database using a single CodeIgniter installation
#9

[eluser]DougW[/eluser]
I found an easier method. It only requires one change to database.php and then a custom index.php for each slave copy of your application.

In index.php, define four variables (more if you want to change more)


define('DATABASE_HOST', 'localhost');
define('DATABASE_USER', 'yourname');
define('DATABASE_PASS', 'yourpass');
define('DATABASE_NAME', 'database');

Then, leave your default database alone, just sent the array variables to the define variables as above...


$db['default']['hostname'] = DATABASE_HOST;
$db['default']['username'] = DATABASE_USER;
$db['default']['password'] = DATABASE_PASS;
$db['default']['database'] = DATABASE_NAME;

All I have to do to spawn an instance of my application is ensure that the system_folder and application_folder variables point to the right places and set the database variables in index.php.

Even config.php is handled by setting base_url as follows:

$config['base_url'] = "http://".$_SERVER['HTTP_HOST'];

Basically, you can have multiple copies of your application by only changing the index.php file.

Hope this helps!

Doug


Messages In This Thread
Multiple systems/database using a single CodeIgniter installation - by El Forum - 02-09-2009, 01:32 AM



Theme © iAndrew 2016 - Forum software by © MyBB