Multiple MySQL connections in modules

Have a programming question regarding your component, plug-in, extension or core hacks? Have an interesting tidbit, FAQ or programming tip you’d like to share? This is the place for you.

Moderators: tjay, seadap, Rogue4ngel, matthewhayashida

Post Reply
bzzik
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Wed May 09, 2007 12:17 pm

Multiple MySQL connections in modules

Post by bzzik » Mon Mar 10, 2008 12:59 pm

Hi guys!

I almost finished my own small module for joomla 1.0, but at the end I faced a problem :(

The thing is that in my module I use MySQL connection to another DB (not to DB in which joomla installed) in such manner:

Code: Select all

$connect = mysql_connect($mysql_addr,$mysql_user,$mysql_pass) or die("Failed to connect to mySQL server");
mysql_select_db($mysql_db, $connect) or die("Could not select database");
and close it with mysql_close($con nect);
but all other joomla modules after mine stops working correctly - they try to use DB form my module.

How can I resolve it? Is it possible to use custom MySQL connections in modules and if yes, how it open and close connections correctly?

Thanks in advance.

bzzik
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Wed May 09, 2007 12:17 pm

Re: Multiple MySQL connections in modules

Post by bzzik » Tue Mar 11, 2008 1:57 pm

Anyone? :(

User avatar
Rogue4ngel
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 199
Joined: Sun Nov 26, 2006 10:46 pm
Location: New York

Re: Multiple MySQL connections in modules

Post by Rogue4ngel » Tue Mar 11, 2008 10:13 pm

Here's a method to connect to another db. Perhaps it will help:
http://dev.joomla.org/component/option, ... _database/
If you're not a part of the solution, you're a part of the problem.

bzzik
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Wed May 09, 2007 12:17 pm

Re: Multiple MySQL connections in modules

Post by bzzik » Wed Mar 12, 2008 1:41 pm

Is it for 1.0 or for 1.5?


Post Reply