Welcome Guest, Not a member yet? Register   Sign In
Global Variables and Two Databases
#2

[eluser]LuckyFella73[/eluser]
You don't have to load the database class in your model.
It's loaded automatically.

All you have to do to switch databases is setting up 2 configurations
in config/database.php and set the active one.
Code:
$active_group = 'default';
#$active_group = 'pro'; // uncomment this line to switch to productive DB
$active_record = TRUE;

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'Your_Username';
$db['default']['password'] = 'Your_Password';
$db['default']['database'] = 'Your_Database';
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;

$db['pro']['hostname'] = 'localhost';
$db['pro']['username'] = 'Your_Username';
$db['pro']['password'] = 'Your_Password';
$db['pro']['database'] = 'Your_Database';
$db['pro']['dbdriver'] = 'mysql';
$db['pro']['dbprefix'] = '';
$db['pro']['pconnect'] = TRUE;
$db['pro']['db_debug'] = TRUE;
$db['pro']['cache_on'] = FALSE;
$db['pro']['cachedir'] = '';
$db['pro']['char_set'] = 'utf8';
$db['pro']['dbcollat'] = 'utf8_general_ci';
$db['pro']['swap_pre'] = '';
$db['pro']['autoinit'] = TRUE;
$db['pro']['stricton'] = FALSE;


Messages In This Thread
Global Variables and Two Databases - by El Forum - 02-25-2011, 09:15 AM
Global Variables and Two Databases - by El Forum - 02-25-2011, 09:31 AM
Global Variables and Two Databases - by El Forum - 02-25-2011, 10:04 AM
Global Variables and Two Databases - by El Forum - 02-25-2011, 10:26 AM
Global Variables and Two Databases - by El Forum - 02-25-2011, 11:14 AM
Global Variables and Two Databases - by El Forum - 02-25-2011, 11:59 AM
Global Variables and Two Databases - by El Forum - 02-25-2011, 12:01 PM
Global Variables and Two Databases - by El Forum - 02-25-2011, 02:31 PM
Global Variables and Two Databases - by El Forum - 02-25-2011, 02:37 PM
Global Variables and Two Databases - by El Forum - 02-25-2011, 02:41 PM
Global Variables and Two Databases - by El Forum - 02-25-2011, 02:47 PM
Global Variables and Two Databases - by El Forum - 02-25-2011, 02:48 PM
Global Variables and Two Databases - by El Forum - 02-25-2011, 03:27 PM



Theme © iAndrew 2016 - Forum software by © MyBB