"$this->load->database('group_name')" doesn't work - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: "$this->load->database('group_name')" doesn't work (/showthread.php?tid=17256) Pages:
1
2
|
"$this->load->database('group_name')" doesn't work - El Forum - 03-31-2009 [eluser]datactrl[/eluser] I have another group than default in database config file, said 'test'. And I do this, $this->load->database('test'). It always use "default" group. I ddin't realise it until I deleted $active_group = "default", I got an error of invalid connection. "$this->load->database('group_name')" doesn't work - El Forum - 03-31-2009 [eluser]Thorpe Obazee[/eluser] try posting your controller. someone is bound to answer... "$this->load->database('group_name')" doesn't work - El Forum - 03-31-2009 [eluser]mindprojects[/eluser] probably you should use this: $db = $this->load->database('test',TRUE). ;-) "$this->load->database('group_name')" doesn't work - El Forum - 04-01-2009 [eluser]datactrl[/eluser] Thanka all. I tried '$db = $this->load->database(‘test’,TRUE)'. The same, it won't work! It always use active_group one. I think it's a bug. "$this->load->database('group_name')" doesn't work - El Forum - 04-01-2009 [eluser]stuffradio[/eluser] Where are you trying to use the other database? Are you doing this in your config file or a separate controller class? If it's a separate controller class, you can load a database by going Code: $DB1 = $this->load->database('group_one', TRUE); Remember: group_one = the name of the first value you use when configuring the database values. So in that case you would go Code: $DB1 = $this->load->database('default', TRUE); "$this->load->database('group_name')" doesn't work - El Forum - 04-01-2009 [eluser]datactrl[/eluser] On database.php, I do ... $active_group = 'default'; $db['default']['hostname'] = "xserver1"; $db['default']['username'] = "test1"; $db['default']['password'] = "postgres"; $db['default']['database'] = "testap"; $db['default']['dbdriver'] = "postgre"; $db['default']['dbprefix'] = ""; $db['default']['pconnect'] = TRUE; $db['default']['db_debug'] = FALSE; $db['default']['cache_on'] = FALSE; $db['default']['cachedir'] = ""; $db['default']['char_set'] = ""; $db['default']['dbcollat'] = ""; $db['test']['hostname'] = "xserver1"; $db['test']['username'] = "test2"; $db['test']['password'] = "postgres"; $db['test']['database'] = "testap"; $db['test']['dbdriver'] = "postgre"; $db['test']['dbprefix'] = ""; $db['test']['pconnect'] = TRUE; $db['test']['db_debug'] = TRUE; $db['test']['cache_on'] = FALSE; $db['test']['cachedir'] = ""; $db['test']['char_set'] = ""; $db['test']['dbcollat'] = ""; On autoload.php, I didn't load database. On my controller, I do ... $this->load->database(‘test’); It actually uses default group. And I found if I delete "$active_group = 'default';", it cause an invalide database connection. "$this->load->database('group_name')" doesn't work - El Forum - 04-01-2009 [eluser]stuffradio[/eluser] Does user test2 have sufficient access to your database? "$this->load->database('group_name')" doesn't work - El Forum - 04-02-2009 [eluser]datactrl[/eluser] Sure, test2 has sufficient access to database. "$this->load->database('group_name')" doesn't work - El Forum - 04-02-2009 [eluser]The Wizard[/eluser] sometimes php has a bug with open and closed db connections or maybe its a feature but in any case, it doesn't behave like we want it to be. so simply use staffradio's method and it should work fine. "$this->load->database('group_name')" doesn't work - El Forum - 09-21-2009 [eluser]t0psub[/eluser] I'm having the same trouble. Based on my login in needs to switch all database connections in my application to the new datbase connection, but calling $this->load->database($domain, TRUE); Isn't switching the database connection. Thoughts |