Query multiple databases - 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: Query multiple databases (/showthread.php?tid=48908) |
Query multiple databases - El Forum - 02-01-2012 [eluser]Eildydar[/eluser] I am trying to query multiple databases within the same page and I am having trouble getting it to work. in my model I have the following. Code: foreach($query->result() as $row) { Code: $mysql = $this->load->database('default'); But I keep getting an error stating "You have not selected a database type". This is a code igniter error and doesn't show up in any logs anywhere for php or apache. Is this something that should be possible? Query multiple databases - El Forum - 02-01-2012 [eluser]meigwilym[/eluser] The guide says you need to pass TRUE as a 2nd argument to the load->database() method. Mei Query multiple databases - El Forum - 02-01-2012 [eluser]Eildydar[/eluser] sorry yes I was passing true, Query multiple databases - El Forum - 02-01-2012 [eluser]meigwilym[/eluser] And did you set the $db['default']['dbdriver'] and $db['osbc']['dbdriver'] correctly? Query multiple databases - El Forum - 02-01-2012 [eluser]Eildydar[/eluser] yes they are set exactly the same one just points to a different server (this is not my end goal but set up that way for testing since that was best way to ensure no issues with config). Copy and paste just changing the host. Query multiple databases - El Forum - 02-02-2012 [eluser]Eildydar[/eluser] Any other ideas? Is this something that CodeIgniter will even support? Query multiple databases - El Forum - 02-02-2012 [eluser]Eildydar[/eluser] So I didn't think to do this before but I tried to just use the odbc link and it doesn't work at all. I have included the entire database.php file below. Not sure if I need to change anything in any other files. Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); Query multiple databases - El Forum - 02-04-2012 [eluser]Eildydar[/eluser] Any ideas? Query multiple databases - El Forum - 02-04-2012 [eluser]CroNiX[/eluser] Connecting to Multiple Databases Code: $mysql = $this->load->database('default', TRUE); Query multiple databases - El Forum - 02-04-2012 [eluser]CroNiX[/eluser] Oh, you said you were. Sorry. |