SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    The knight who said ni! RockyShark's Avatar
    Join Date
    Apr 2003
    Location
    Rockhampton, Australia
    Posts
    701
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Querying Multiple Databases

    Greetings!

    I currently have a separate MySQL database for each client, as much of their stuff is different, however the table that logs their site statistics is the same in each db. As part of that reporting, I also have a table that matches IP addresses to Country, which I have to reproduce in each database.

    So is it possible to have the IP-to-Country table in one database, and then query two databases at the same time? Or is my only option to keep reproducing the IP-to-Country table in each db?

    Thanks!

  2. #2
    SitePoint Guru dragonhawk's Avatar
    Join Date
    Apr 2002
    Location
    Melbourne
    Posts
    707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What I do is I have a default db to hold all the common information from all the clients. Then in the code, I would connect to the relevant db's using mysql_select_db() to query the client's information. Once I got the client's information, I stored what was needed in variables and then went back to the default db (using mysql_select_db again). I don't think you can query multiple databases at the same time.

  3. #3
    The knight who said ni! RockyShark's Avatar
    Join Date
    Apr 2003
    Location
    Rockhampton, Australia
    Posts
    701
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks dragonhawk, how do you go retrieving large amounts of data from the client databases? If you're retrieving thousands of rows from the client's database before switching back, large amounts of info can be stored in variables okay?

  4. #4
    SitePoint Guru dragonhawk's Avatar
    Join Date
    Apr 2002
    Location
    Melbourne
    Posts
    707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yea, should have no problem storing in variables. You can use arrays to store all the information if you need to organise it in a single variable or you can store each value into different variables. Depending on what you're storing, you might use an array or individual variables.

    For eg, if you are querying multiple client's at a time, then arrays would be better. A new array for a new client. If only a single client, then you can use individual variables. Though I personally would go for an array in any case

  5. #5
    The knight who said ni! RockyShark's Avatar
    Join Date
    Apr 2003
    Location
    Rockhampton, Australia
    Posts
    701
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cheers dragonhawk - I'll give that a try.

    Thanks!


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
  •