Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

1 db or 2 in mySql with PHP



12:28 am on May 21, 2001 (gmt 0)

10+ Year Member

With PHP, is a script accessing 2 databases on the same account more intensive then using just one database.

Example, the first database has news articles, the second forums, and the third a user database. These are all relating to the same site.

Is there any benefit putting them all in one db, aside from organzational issues?

Do you have to connect twice to the db, or once? Server implications?

Thanks, Joseph


12:37 am on May 21, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

Hi jetsetter.

Thats a nice nuke site you got there. I can't answer the specifics about the connections to the bases other than to note that if you're running the news out of one and the forums out of the other than the user will always be requesting from one or the other....e.g they won't be fetching news from the forum page and they won't be fetchingforum threads from the news pages. So you will be accessing one database or the other at any one time. I'm thinking there shouldn't be any noticable differences in base connection times.

The upcoming release of Nuke 5.0 has addressed the multiple database problem and now prefaces all the tables with nuke_**** so you can run simultaneous programs from one base.


2:24 am on May 21, 2001 (gmt 0)

10+ Year Member

Hi, thanks for the kind words.

I'm actually asking a general question about the way mysql works.

I can code a page to pull data from 2 or more different databases using the mysql_select_db() command.

I'm just wondering if that means I'm opening one or multiple mysql sessions?



8:56 am on May 21, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

You would only be opening one session.

Once you open a connection using mysql_connect(), that connection stays alive until you either close it or the script finishes. You can then use mysql_select_db() as you say to choose which DB to access over the connection you've opened.

This is a good point you've brought up Joe, as it makes sense to avoid (when you can) the processing overhead that connection / disconnection involves.


Featured Threads

Hot Threads This Week

Hot Threads This Month