Connecting to Other Databases

Permalink
Hi All,

I was trying to connect to another database outside the C5 one, i found this link under the documentation;

http://www.concrete5.org/documentation/developers/system/database-c...

I tried the part the reads:

Connecting to Other Databases

Developers are able to switch active database throughout a session with a simple command

But i couldn't get it to work, is this still supported?

mdzoidberg
 
mdzoidberg replied on at Permalink Reply
mdzoidberg
Anybody?
okhayat replied on at Permalink Best Answer Reply
okhayat
Not sure if it's still supported, but surely you can use 'select * from db.table' if the same user has access to both DBs.
mdzoidberg replied on at Permalink Reply
mdzoidberg
Hey okhayat, thanks for the suggestion, unfortunately the user does not have the same login info. I can always load another connection since this is a helper but i was hoping to keep everything under the C5 framework.
andrew replied on at Permalink Reply
andrew
It should still be supported, yeah.
mdzoidberg replied on at Permalink Reply
mdzoidberg
Im trying to use this on a helper, I tried the code below but got an error about the table not existing on the current C5 DB, so it seems like it's not trying to connect to the external DB

public function TestExternal() {
$db = Loader::db( 'localhost', 'MyUser', 'MyPass', 'MyDB', true);
$db->Execute('SELECT * FROM TABLE');
// return to the original db session
$db = Loader::db(null, null, null, null, true);
    }


Any help is appreciated.
tbcrowe replied on at Permalink Reply
tbcrowe
I've had trouble with that working as well. What I've done is make my own loader class that does the same thing as Loader::db except that the following line is commented out:
ADOdb_Active_Record::SetDatabaseAdapter($_dba);

For some reason that call causes problems for the new connection.
mdzoidberg replied on at Permalink Reply
mdzoidberg
Thanks tbcrowe, i tried your suggestion but didn't work, I'm using 5.4.0.5, does that make a difference?

What version are you using?