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?
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?
Anybody?
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.
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.
It should still be supported, yeah.
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
Any help is appreciated.
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.
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:
For some reason that call causes problems for the new connection.
ADOdb_Active_Record::SetDatabaseAdapter($_dba);
For some reason that call causes problems for the new connection.
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?
What version are you using?