数据库.php:
$db['default']['hostname'] = "192.168.2.104";
$db['default']['username'] = "webuser";
$db['default']['password'] = "----";
$db['default']['database'] = "vad";
$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['stats']['hostname'] = "192.168.2.104";
$db['stats']['username'] = "webuser";
$db['stats']['password'] = "---";
$db['stats']['database'] = "vad_stats";
$db['stats']['dbdriver'] = "mysql";
$db['stats']['dbprefix'] = "";
$db['stats']['pconnect'] = TRUE;
$db['stats']['db_debug'] = TRUE;
$db['stats']['cache_on'] = FALSE;
$db['stats']['cachedir'] = "";
$db['stats']['char_set'] = "utf8";
$db['stats']['dbcollat'] = "utf8_general_ci";
问题是我只能在配置一
$active_group
、默认值或统计信息中定义。我遵循了 CodeIgniter 文档并添加了以下内容:
$DB2 = $this->load->database('stats', TRUE);
这样我连接到第二个数据库,但我失去了与第一个数据库的连接。有没有人知道如何加载两个数据库而不必在所有模型构造函数中执行以下操作?
$database1 = $this->load->database('database1', TRUE);
$database2 = $this->load->database('database2', TRUE);
问候,
佩德罗