CodeIgniter Forums
changing databases via $active_group? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11)
+--- Thread: changing databases via $active_group? (/showthread.php?tid=76721)



changing databases via $active_group? - richb201 - 06-12-2020

I managed to get postgres connected. Here is the connection:

$DB1 = $this->load->database('default', TRUE);
$DB2 = $this->load->database('postgres', TRUE);


My connection to mySQL still works fine without any changes. How do I change the $active_group? I see how to change it in database.php, but I need to change it "on the fly". The image_crud uses $this->ci->db and I'd like it to use $DB2. Is there some way to load a second ci->db structure? 

Also, where did the codeigniter3 documentation go? 


RE: changing databases via $active_group? - richb201 - 06-15-2020

Ok. It seems clear that there is no way to switch the $active_group. The CI developers smartly added the ability to open more than one database. But seemed to leave out the ability to change the default database to use. Great.

The Image CRUD library I am using seems want to use the default database. I am out of ideas.