我必須從主數據庫檢索MySQL數據庫信息,然後連接到該數據庫並獲取一些記錄。Codeigniter - 多個數據庫連接
我的意思是拿着一個數據庫我想加載另一個數據庫。
Codeigniter可以嗎?現在我在我的模型中使用了以下幾行代碼。
function connectDb($credential)
{
$config['hostname'] = $credential['server'];
$config['username'] = $credential['username'];
$config['password'] = $credential['password'];
$config['database'] = $credential['database'];
$config['dbdriver'] = "mysql";
$config['dbprefix'] = "";
$config['pconnect'] = FALSE;
$config['db_debug'] = TRUE;
$config['cache_on'] = FALSE;
$config['cachedir'] = "";
$config['char_set'] = "utf8";
$config['dbcollat'] = "utf8_general_ci";
$DB2=$this->load->database($config);
$DB2->db->select('first_name,last_name');
$query = $DB2->db->get('person');
print_r($query);
}
它不工作有沒有其他辦法?
定義「不工作」 –