Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter helpful hints
#24

[eluser]Référencement Google[/eluser]
One more tip that I use. I define in my config.php a constant that says if I am on my production server or on my localhost. It allow me then to reach different settings that are switched automatically, example with the base URL:

Code:
define('IS_PRODUCTION', ($_SERVER['SERVER_NAME'] != 'localhost'));
                      
if(IS_PRODUCTION)
{
    $config['base_url'] = 'http://www.yoursite.com';
}
else
{
    $config['base_url'] = 'http://localhost/yoursite/';
}

Or for example in the database.php file:
Code:
if(IS_PRODUCTION)
{
    $active_group = 'production';
}
else
{
    $active_group = 'local';
}
                
$active_record = TRUE;

$db['local']['hostname'] = "localhost";
$db['local']['username'] = "root";
$db['local']['password'] = "pass";
$db['local']['database'] = "dbname";
$db['local']['dbdriver'] = "mysql";
$db['local']['dbprefix'] = "";
$db['local']['pconnect'] = FALSE;
$db['local']['db_debug'] = TRUE;
$db['local']['cache_on'] = FALSE;
$db['local']['cachedir'] = "";
$db['local']['char_set'] = "utf8";
$db['local']['dbcollat'] = "utf8_general_ci";

$db['production']['hostname'] = "localhost";
$db['production']['username'] = "production_user";
$db['production']['password'] = "production_pass";
$db['production']['database'] = "production_db";
$db['production']['dbdriver'] = "mysql";
$db['production']['dbprefix'] = "";
$db['production']['pconnect'] = FALSE;
$db['production']['db_debug'] = FALSE;
$db['production']['cache_on'] = FALSE;
$db['production']['cachedir'] = "";
$db['production']['char_set'] = "utf8";
$db['production']['dbcollat'] = "utf8_general_ci";


Messages In This Thread
CodeIgniter helpful hints - by El Forum - 02-07-2008, 08:03 PM
CodeIgniter helpful hints - by El Forum - 02-07-2008, 10:57 PM
CodeIgniter helpful hints - by El Forum - 02-07-2008, 11:30 PM
CodeIgniter helpful hints - by El Forum - 02-08-2008, 12:32 AM
CodeIgniter helpful hints - by El Forum - 02-08-2008, 06:24 AM
CodeIgniter helpful hints - by El Forum - 02-08-2008, 07:17 AM
CodeIgniter helpful hints - by El Forum - 02-08-2008, 07:37 AM
CodeIgniter helpful hints - by El Forum - 02-08-2008, 10:36 PM
CodeIgniter helpful hints - by El Forum - 02-08-2008, 10:52 PM
CodeIgniter helpful hints - by El Forum - 02-09-2008, 12:14 AM
CodeIgniter helpful hints - by El Forum - 02-09-2008, 01:57 AM
CodeIgniter helpful hints - by El Forum - 02-12-2008, 02:25 AM
CodeIgniter helpful hints - by El Forum - 02-12-2008, 03:01 AM
CodeIgniter helpful hints - by El Forum - 02-12-2008, 11:29 AM
CodeIgniter helpful hints - by El Forum - 02-12-2008, 04:30 PM
CodeIgniter helpful hints - by El Forum - 02-12-2008, 08:53 PM
CodeIgniter helpful hints - by El Forum - 02-14-2008, 03:41 AM
CodeIgniter helpful hints - by El Forum - 02-14-2008, 06:46 AM
CodeIgniter helpful hints - by El Forum - 02-14-2008, 07:47 AM
CodeIgniter helpful hints - by El Forum - 02-14-2008, 09:52 AM
CodeIgniter helpful hints - by El Forum - 02-19-2008, 08:47 AM
CodeIgniter helpful hints - by El Forum - 02-19-2008, 09:38 AM
CodeIgniter helpful hints - by El Forum - 02-19-2008, 09:41 AM
CodeIgniter helpful hints - by El Forum - 02-19-2008, 06:43 PM
CodeIgniter helpful hints - by El Forum - 02-19-2008, 10:15 PM
CodeIgniter helpful hints - by El Forum - 02-20-2008, 01:35 AM
CodeIgniter helpful hints - by El Forum - 02-20-2008, 02:06 AM
CodeIgniter helpful hints - by El Forum - 02-20-2008, 03:00 AM
CodeIgniter helpful hints - by El Forum - 02-26-2008, 08:13 AM
CodeIgniter helpful hints - by El Forum - 03-06-2008, 04:38 AM
CodeIgniter helpful hints - by El Forum - 03-06-2008, 08:32 AM
CodeIgniter helpful hints - by El Forum - 04-03-2008, 10:19 AM
CodeIgniter helpful hints - by El Forum - 04-04-2008, 10:07 PM
CodeIgniter helpful hints - by El Forum - 04-11-2008, 03:13 AM
CodeIgniter helpful hints - by El Forum - 04-18-2008, 06:35 AM
CodeIgniter helpful hints - by El Forum - 04-28-2008, 10:34 PM
CodeIgniter helpful hints - by El Forum - 05-14-2008, 01:23 AM
CodeIgniter helpful hints - by El Forum - 05-15-2008, 05:48 AM
CodeIgniter helpful hints - by El Forum - 06-18-2008, 02:40 AM
CodeIgniter helpful hints - by El Forum - 07-09-2008, 05:03 AM
CodeIgniter helpful hints - by El Forum - 07-09-2008, 05:05 AM
CodeIgniter helpful hints - by El Forum - 07-30-2008, 04:45 AM



Theme © iAndrew 2016 - Forum software by © MyBB