rlargett
11/1/2010 - 4:00 PM

Inside config/database.php: Use a switch statement and the active group in EE2 to set database information based on which server you're curr

Inside config/database.php: Use a switch statement and the active group in EE2 to set database information based on which server you're currently accessing.

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

// Multiple if statements, or a switch statement,
// can handle as many environments as you need
if ($_SERVER['HTTP_HOST'] == "local-site.dev") {
    $active_group = 'expressionengine';
} else {
    $active_group = 'enginehosting';
}

$active_record = TRUE;

$db['expressionengine']['hostname'] = "localhost";

$db['expressionengine']['username'] = "local username";
$db['expressionengine']['password'] = "local password";
$db['expressionengine']['database'] = "local database";

$db['expressionengine']['dbdriver'] = "mysql";
$db['expressionengine']['dbprefix'] = "exp_";
$db['expressionengine']['pconnect'] = FALSE;
$db['expressionengine']['swap_pre'] = "exp_";
$db['expressionengine']['db_debug'] = TRUE;
$db['expressionengine']['cache_on'] = FALSE;
$db['expressionengine']['autoinit'] = FALSE;
$db['expressionengine']['char_set'] = "utf8";
$db['expressionengine']['dbcollat'] = "utf8_general_ci";
$db['expressionengine']['cachedir'] = "";

// Copies most of the settings from the above connection
$db['enginehosting'] = $db['expressionengine'];
$db['enginehosting']['hostname'] = "production server hostname";
$db['enginehosting']['username'] = "production server username";
$db['enginehosting']['database'] = "production server database";



/* End of file database.php */
/* Location: ./system/expressionengine/config/database.php */