codeigniter访问database.php中的config.php

时间:2011-03-22 00:19:41

标签: php codeigniter configuration-files

在我的工作中,我们有一个典型的设置

开发localhost
测试分期 继续生产

我们正在使用codeigniter。

显然,每次我们移动它们时都必须更改所有设置真的很痛苦。

我想做的是。

config.php中的

$config['env'] = 'localhost'; //'test'; //'production';

然后在我的database.phpemail.php

$env = //config env variable

if($env === 'localhost'){
  //localhost settings
} elseif($env === 'test'){
  //staging settings
} elseif($env === 'production'){
  //production settings
}

我该怎么做?

1 个答案:

答案 0 :(得分:0)

在1.7.x中你可以这样做:

在database.php中:

$CI = get_instance();
$active_group = $CI->config->item("active_group");

所以在config.php中你可以拥有:

$config['active_group'] = 'development'; // production, staging, etc
相关问题