Results 1 to 7 of 7

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

  1. #1
    Junior Registered
    Join Date
    Apr 2008
    Posts
    3

    In MySQL, possible to use two database in one PHP web application...?

    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?
    soberpacificliving - Orange County Sober Living Home Residence.

  2. #2
    4x4
    Join Date
    Oct 2004
    Posts
    1,043
    You can use 2 different databases in one application.

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

  3. #3
    Administrator Chris's Avatar
    Join Date
    Feb 2003
    Location
    East Lansing, MI USA
    Posts
    7,055
    I think you've got databases and tables confused.

    Tables have keys, tables have relationships.
    Chris Beasley - My Guide to Building a Successful Website[size=1]
    Content Sites: ABCDFGHIJKLMNOP|Forums: ABCD EF|Ecommerce: Swords Knives

  4. #4
    Registered
    Join Date
    Jun 2004
    Posts
    35
    Quote Originally Posted by jackbabington View Post
    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.
    WEBster Computing Services - webcs.com
    Linux and Windows shared hosting | DEDICATED server hosting
    One of the oldest hosts on the planet
    Since 1996............just ask us

  5. #5
    Gimme Fries with that!
    Join Date
    Aug 2004
    Posts
    1,469
    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.

  6. #6
    Administrator Chris's Avatar
    Join Date
    Feb 2003
    Location
    East Lansing, MI USA
    Posts
    7,055
    Really? Four? Why?
    Chris Beasley - My Guide to Building a Successful Website[size=1]
    Content Sites: ABCDFGHIJKLMNOP|Forums: ABCD EF|Ecommerce: Swords Knives

  7. #7
    Gimme Fries with that!
    Join Date
    Aug 2004
    Posts
    1,469
    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.

Similar Threads

  1. Replies: 0
    Last Post: 01-04-2006, 10:40 PM
  2. Replies: 0
    Last Post: 12-22-2005, 09:42 AM
  3. Replies: 0
    Last Post: 11-23-2005, 04:49 AM
  4. Clear my misunderstanding: 1 MySQL database for many programs?
    By iKwak in forum Website Programming & Databases
    Replies: 4
    Last Post: 08-21-2005, 10:40 AM
  5. Replies: 0
    Last Post: 10-29-2004, 09:43 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •