我尝试连接到CI中的多个MySQL数据库
如果与第一个DB的连接失败,我尝试连接到第二个,
我在CI论坛中使用此代码:
http://ellislab.com/forums/viewthread/224522/#1030449
$db_obj = $this->database->load('xxx',TRUE);
$connected = $db_obj->initialize();
if (!$connected) {
$db_obj = $this->database->load('yyy',TRUE);
}
它在本地主机上工作正常,它尝试连接到第一个DB并失败,然后直接连接到第二个DB(没有任何长时间 - 透明度)
但
当我将代码移动到在线服务器时,尝试连接到第一个DB需要很长时间,然后(在此超时之后)它尝试连接第二个DB并成功了
我怎样才能删除这个等待时间?我需要它直接尝试连接到失败案例中的其他数据库
我的数据库配置如下:
$db['DB1']['hostname'] = '1.1.1.1';
$db['DB1']['username'] = 'test';
$db['DB1']['password'] = '123456';
$db['DB1']['database'] = 'db1';
$db['DB1']['dbdriver'] = 'mysql';
$db['DB1']['dbprefix'] = '';
$db['DB1']['pconnect'] = TRUE;
$db['DB1']['db_debug'] = FALSE;
$db['DB1']['cache_on'] = FALSE;
$db['DB1']['cachedir'] = '';
$db['DB1']['char_set'] = 'utf8';
$db['DB1']['dbcollat'] = 'utf8_general_ci';
$db['DB1']['swap_pre'] = '';
$db['DB1']['autoinit'] = FALSE;
$db['DB1']['stricton'] = FALSE;
$db['DB2']['hostname'] = '1.1.1.1';
$db['DB2']['username'] = 'test';
$db['DB2']['password'] = '123456';
$db['DB2']['database'] = 'db2';
$db['DB2']['dbdriver'] = 'mysql';
$db['DB2']['dbprefix'] = '';
$db['DB2']['pconnect'] = TRUE;
$db['DB2']['db_debug'] = FALSE;
$db['DB2']['cache_on'] = FALSE;
$db['DB2']['cachedir'] = '';
$db['DB2']['char_set'] = 'utf8';
$db['DB2']['dbcollat'] = 'utf8_general_ci';
$db['DB2']['swap_pre'] = '';
$db['DB2']['autoinit'] = FALSE;
$db['DB2']['stricton'] = FALSE;
非常感谢!