Welcome Guest, Not a member yet? Register   Sign In
Multiple databases $this->db->join
#1

[eluser]Maaark[/eluser]
Hello,

Currently I have this not working code in my model:

Code:
$this->db_site->order_by('id', 'random');
        $select = $this->db_site->get_where('berichten', array('fake' => 1, 'beantwoord' => 0, 'gelezen' => 0));
        
        $this->db->join('replymessages', 'replymessages.msgid != berichten.id');
        $this->db->join('replymessages', 'replymessages.time > '.time());

In this example the joins won'y work for the db_site query's, is there a methode to do a join from an other database?

Thanks
#2

[eluser]Maaark[/eluser]
bump
#3

[eluser]rogierb[/eluser]
Using the db active record it is probably possible but not like your trying now. This will just generate 2 different queries, one for each database.

First try it with a 'normal' sql query like
<code>
Select t1.id, t2.* from db1.mytable t1
left join db2.another_table t2 on (t1.id = td.first_id)
</code>

If you got the working try to rewrite it using active record using only one class.
As long as you make sure your connected to both databases it should work.

I've done it in the past although i'm not sure if it worked with active record
#4

[eluser]Maaark[/eluser]
But how can I do a 'normal' query if the database's belong to other users at the server?
#5

[eluser]stuckinphp[/eluser]
I do this with postgres dblink on the odd occasion, looks like you're using mysql though. All I can say is, good luck Wink

http://stackoverflow.com/questions/11857...ink-module




Theme © iAndrew 2016 - Forum software by © MyBB