Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter MultiDatabse connect error
#1

[eluser]Unknown[/eluser]
I see a lot of method/tutorial to connect multi database in CodeIgniter? Still far far away with me. Some one provide me to connect multi database in CI. This is my using way i was found it in a blog. pardon me, i don't recognize the blog address.
Code:
$active_group = 'default';
    $active_record = TRUE;
    $db['default']['hostname'] = 'localhost';
    $db['default']['username'] = 'root';
    $db['default']['password'] = 'root';
    $db['default']['database'] = 'vk_global';
    $db['default']['dbdriver'] = 'mysql';
    $db['default']['dbprefix'] = '';
    $db['default']['pconnect'] = TRUE;
    $db['default']['db_debug'] = TRUE;
    $db['default']['cache_on'] = FALSE;
    $db['default']['cachedir'] = '';
    $db['default']['char_set'] = 'utf8';
    $db['default']['dbcollat'] = 'utf8_general_ci';
    $db['default']['swap_pre'] = '';
    $db['default']['autoinit'] = TRUE;
    $db['default']['stricton'] = FALSE;

    //add alternate database settings
    $db['wow']['hostname'] = 'localhost';
    $db['wow']['username'] = 'root';
    $db['wow']['password'] = 'root';
    $db['wow']['database'] = 'auth';
    $db['wow']['dbdriver'] = 'mysql';
    $db['wow']['dbprefix'] = '';
    $db['wow']['pconnect'] = TRUE;
    $db['wow']['db_debug'] = TRUE;
    $db['wow']['cache_on'] = FALSE;
    $db['wow']['cachedir'] = '';
    $db['wow']['char_set'] = 'utf8';
    $db['wow']['dbcollat'] = 'utf8_general_ci';
    $db['wow']['swap_pre'] = '';
    $db['wow']['autoinit'] = TRUE;
    $db['wow']['stricton'] = FALSE;

i was call it with this code
Code:
$DB2 = $this->load->database('auth',true);
. and i was insert a simple row with this code
Code:
$this->$DB2->insert('events_grouptable',$data);
i got this error You have specified an invalid database connection group. how should i solve this error?
#2

[eluser]Aken[/eluser]
Use the group name ("wow") not the database name.




Theme © iAndrew 2016 - Forum software by © MyBB