Welcome Guest, Not a member yet? Register   Sign In
Query multiple databases
#1

[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) {
          $data[] = $row;
      }
And that works fine but if I try and add

Code:
$mysql = $this->load->database('default');
$odbc = $this->load->database('odbc');

$query = $mysql->query("SELECT * FROM db");
foreach($query->result() as $row) {
          $q = $odbc->query("SELECT * FROM otherDb WHERE field = $row->field");
          $result = $q->result()
          $return = array_merge($row, $result);
          $data[] = $return;
      }

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?


Messages In This Thread
Query multiple databases - by El Forum - 02-01-2012, 04:02 PM
Query multiple databases - by El Forum - 02-01-2012, 04:18 PM
Query multiple databases - by El Forum - 02-01-2012, 04:20 PM
Query multiple databases - by El Forum - 02-01-2012, 05:09 PM
Query multiple databases - by El Forum - 02-01-2012, 05:15 PM
Query multiple databases - by El Forum - 02-02-2012, 11:50 AM
Query multiple databases - by El Forum - 02-02-2012, 12:16 PM
Query multiple databases - by El Forum - 02-04-2012, 06:52 PM
Query multiple databases - by El Forum - 02-04-2012, 09:41 PM
Query multiple databases - by El Forum - 02-04-2012, 09:41 PM



Theme © iAndrew 2016 - Forum software by © MyBB