私はCodeIgniterといくつかのMySQLデータベースを持っています。しかし、私は作業のために別のデータベースを設定したいと思っています。例えば、私は()関数のmake_some_actions_with_dbを持って、そして今私はそのような何か持っている必要があります。今、私は新しいデフォルトのDBを設定することができますし、どのように私は最初の(別の設定方法を知る必要があり、そうCodeIgniterを使用して別のデータベースを読み込む方法は?
public function action()
{
//load db
make_some_actions_with_db();
//disable db
}
を)db。ありがとうございました。
更新日: それは動作しません:
public function update_record_insert_test()
{
if ($this->facebook->getUser())
{
$another_db_settings['hostname'] = 'localhost';
$another_db_settings['username'] = 'root';
$another_db_settings['password'] = '';
$another_db_settings['database'] = 'name';
$another_db_settings['dbdriver'] = "mysql";
$another_db_settings['dbprefix'] = "";
$another_db_settings['pconnect'] = TRUE;
$another_db_settings['db_debug'] = TRUE;
$another_db_settings['cache_on'] = FALSE;
$another_db_settings['cachedir'] = "";
$another_db_settings['char_set'] = "utf8";
$another_db_settings['dbcollat'] = "utf8_general_ci";
$this->load->database($another_db_settings);
$_POST['id']='AccountPagesView.a_book/1000';
$_POST['value']='test';
$_POST['old_value']='not';
$welcome=new Welcome();
$welcome->update_record();
}
else
{
$url=$this->facebook->getLoginUrl(array('next' => base_url().'update_record_insert_test'));
redirect($url);
}
}
を介して他の変数への新しい接続を割り当てます> DB->取得(.. 。)、私はこのコードを変更することはできませんが、同じテーブルを持つ同じdbがある、私はこれをデフォルトのdbを変更する必要があります。私はそれをどのようにすることができますか?たとえば、今は "db1"データベースがあり、2番目は "db1_copy"です - これと同じような$ this-> db->という要求はすべて "db1_copy"で実行される必要があります。 – user1477886
設定を変更できる場合は、 'default'グループの詳細を 'db1_copy'の詳細に変更してください。それは動作するはずですか? – cchana
いいえ、私はちょうど試したが、それは動作しません。 – user1477886