0
我正在使用codeigniter mongo類。我將配置信息(如mongohost,mongodb名稱等)存儲在codeigniter中的config/mongo.php中。但是,我想在我的代碼中的某些地方切換db名稱,而不必每次都重新編寫config/mongo.php。是否有開關數據庫功能或任何其他方式?在Codeigniter Mongo類中切換數據庫
我正在使用codeigniter mongo類。我將配置信息(如mongohost,mongodb名稱等)存儲在codeigniter中的config/mongo.php中。但是,我想在我的代碼中的某些地方切換db名稱,而不必每次都重新編寫config/mongo.php。是否有開關數據庫功能或任何其他方式?在Codeigniter Mongo類中切換數據庫
You can set another in the config aside from your default one:
// your code
$this->load->database('test');
// config
$db['test']['hostname'] = "localhost";
$db['test']['username'] = "root";
$db['test']['password'] = "";
$db['test']['database'] = "database_name";
$db['test']['dbdriver'] = "mysql";
$db['test']['dbprefix'] = "";
$db['test']['pconnect'] = TRUE;
$db['test']['db_debug'] = FALSE;
$db['test']['cache_on'] = FALSE;
$db['test']['cachedir'] = "";
$db['test']['char_set'] = "utf8";
$db['test']['dbcollat'] = "utf8_general_ci";
$db['test']['swap_pre'] = "";
$db['test']['autoinit'] = TRUE;
$db['test']['stricton'] = FALSE;