Multiple connections

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
user___
Forum Contributor
Posts: 297
Joined: Tue Dec 05, 2006 3:05 pm

Multiple connections

Post by user___ »

Hu guys.,
I am developing an application that needs to connect to some databases (not as usuall to one). I have developed a class that swaps between the two databases by first closing the first database and then opens the second and finally close the second and opens the first. I wonder whether this is the best approach and whether this is the best approach and whether it consumes a lot of power?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Do you use the same connection parameters for both? Parameters being username, password, server string and port. If so, you can query the database without changing the current one.

Code: Select all

SELECT fieldName from databaseName.tableName ...
user___
Forum Contributor
Posts: 297
Joined: Tue Dec 05, 2006 3:05 pm

Reply

Post by user___ »

Actually, it was not the case to use the same username and password... but I modified my script and now it is.
BTW, sometimes simple things just slip from my mind.
Thank you, feyd.
Post Reply