PDA

View Full Version : In MySQL, possible to use two database in one PHP web application...?



jackbabington
05-19-2008, 10:10 AM
Hi...

I am doing simple PHP program with mysql as my back end database and I want to do some experiment and want to ask first from you...

In my sql, is it possible to use two database in my one web application?
and of course the two databases have the relationship as for example: the primary key is in the FIRST database and its foreign key is in the SECOND database?

if it is possible, how can I create a select statement to select a certain column in FIRST and SECOND database?

Todd W
05-19-2008, 11:47 AM
You can use 2 different databases in one application.

I think you are asking if you can use two different databases in one query??

Chris
05-19-2008, 02:58 PM
I think you've got databases and tables confused.

Tables have keys, tables have relationships.

webcs
07-01-2008, 07:44 AM
Hi...

I am doing simple PHP program with mysql as my back end database and I want to do some experiment and want to ask first from you...

In my sql, is it possible to use two database in my one web application?
and of course the two databases have the relationship as for example: the primary key is in the FIRST database and its foreign key is in the SECOND database?

if it is possible, how can I create a select statement to select a certain column in FIRST and SECOND database?

YES! You can do this. What you have to do is open ONE database, then close it (close statement). Then open the other one and close it. Do not open both at the same time or you are going to run into server and code problems.

Emancipator
07-16-2008, 03:37 PM
i am not clear on the only using one database at a time. I use up to 4 at one time. No problems at all. Key is do not use persistent connections,close em when they are not needed and make sure your hosting on a good server if you get any kind of traffic.

Chris
07-16-2008, 05:48 PM
Really? Four? Why?

Emancipator
07-20-2008, 11:02 AM
initially HORRIBLE understanding of sql. :) You are the best person to know when I started out I did not know **** from putty but after over 5 years of coding I have evolved. NOt saying its good but that it can definitely be done.

I am switching to xml and spry to access multiple databases of content across relevant sites, as well as merging databases.