2016-04-27 77 views

回答

2

嘗試是這樣的:

配置:

$active_group = 'default'; 
$db['default']['hostname'] = 'localhost'; 
$db['default']['username'] = 'root'; 
$db['default']['password'] = ''; 
$db['default']['database'] = 'test1'; 


//Another database connection. 
$db['db2']['hostname'] = 'localhost'; 
$db['db2']['username'] = 'root'; 
$db['db2']['password'] = ''; 
$db['db2']['database'] = 'test2'; 

控制器:

// close the default connection 
$this->db->close(); 
// connect to the other db 
$this->db = $this->load->database('db2', true); 
相關問題