Skip to content

Instantly share code, notes, and snippets.

@ryanbattles
Created September 14, 2011 13:59
Show Gist options
  • Save ryanbattles/1216627 to your computer and use it in GitHub Desktop.
Save ryanbattles/1216627 to your computer and use it in GitHub Desktop.
A database.php file for ExpressionEngine 2.x that allows for multiple server environments.
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
if ($_SERVER['SERVER_ADDR'] == '') {
$active_group = 'staging';
} elseif ($_SERVER['SERVER_ADDR'] == '208.73.210.85') { /* using qa-zone.com */
$active_group = 'production';
} else {
$active_group = 'development';
}
$active_record = TRUE;
/*-----------------------------------
Development
-------------------------------------*/
$db['development']['hostname'] = "localhost";
$db['development']['username'] = "xxx";
$db['development']['password'] = "xxx";
$db['development']['database'] = "xxx_ee";
$db['development']['dbdriver'] = "mysql";
$db['development']['dbprefix'] = "exp_";
$db['development']['pconnect'] = FALSE;
$db['development']['swap_pre'] = "exp_";
$db['development']['db_debug'] = FALSE;
$db['development']['cache_on'] = FALSE;
$db['development']['autoinit'] = FALSE;
$db['development']['char_set'] = "utf8";
$db['development']['dbcollat'] = "utf8_general_ci";
$db['development']['cachedir'] = "{$_SERVER['DOCUMENT_ROOT']}/admin/expressionengine/cache/db_cache/";
/*-----------------------------------
Staging
-------------------------------------*/
$db['staging']['hostname'] = "localhost";
$db['staging']['username'] = "xxx";
$db['staging']['password'] = "xxx";
$db['staging']['database'] = "xxx_ee";
$db['staging']['dbdriver'] = "mysql";
$db['staging']['dbprefix'] = "exp_";
$db['staging']['pconnect'] = FALSE;
$db['staging']['swap_pre'] = "exp_";
$db['staging']['db_debug'] = FALSE;
$db['staging']['cache_on'] = FALSE;
$db['staging']['autoinit'] = FALSE;
$db['staging']['char_set'] = "utf8";
$db['staging']['dbcollat'] = "utf8_general_ci";
$db['staging']['cachedir'] = "{$_SERVER['DOCUMENT_ROOT']}/admin/expressionengine/cache/db_cache/";
/*-----------------------------------
Production
-------------------------------------*/
$db['production']['hostname'] = "localhost";
$db['production']['username'] = "xxx";
$db['production']['password'] = "xxx";
$db['production']['database'] = "xxx_ee";
$db['production']['dbdriver'] = "mysql";
$db['production']['dbprefix'] = "exp_";
$db['production']['pconnect'] = FALSE;
$db['production']['swap_pre'] = "exp_";
$db['production']['db_debug'] = FALSE;
$db['production']['cache_on'] = TRUE;
$db['production']['autoinit'] = FALSE;
$db['production']['char_set'] = "utf8";
$db['production']['dbcollat'] = "utf8_general_ci";
$db['production']['cachedir'] = "{$_SERVER['DOCUMENT_ROOT']}/admin/expressionengine/cache/db_cache/";
/* End of file database.php */
/* Location: ./system/expressionengine/config/database.php */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment