Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Data Model Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

External Database

Go to End

5 Posts   2539 Views


Community Member, 791 Posts

12 November 2009 at 2:13am

Edited: 12/11/2009 2:15am

Continuing this old thread :

The thread is about connecting to external MySQL MySQL databases. And the guys figures out that in order for this to work, the core MySQLDatabase class needs to be altered to create a new MYSQL Link every time ....

Sam ends with :
"Setting the new_link parameter seems appropriate; the alternative would be to call "USE xxx" before each database query which would get annoying, especially given that multi-database access is a pretty rare scenario."

My questions:
Is this still the "official" way of pulling data from an external database ? Should I expect any adverse results from creating a new DB_link every time (garbage collection / mem usage / performance issues etc.)

Thanks !


Forum Moderator, 801 Posts

2 December 2009 at 9:42pm

Wow, thats a seriously old thread ;) You can have named connections via DB::getConn(<my-name>) now


Community Member, 41 Posts

21 January 2010 at 7:56am

Edited: 21/01/2010 7:57am

This is the code for DB::getConn()...

* Get the global database connection.
* @return Database
static function getConn() {
return DB::$globalConn;

It doesn't look like it supports named connections unless I'm missing something. Can you post an example?



Forum Moderator, 801 Posts

21 January 2010 at 8:18am

It's in 2.4 alpha1, sorry!


Community Member, 41 Posts

21 January 2010 at 8:28am

Thanks for the quick response.

Just one more thing to look forward to in 2.4 :)