Results 1 to 3 of 3

Thread: Connecting to MySQL over multiple pages

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2006
    Location
    Ithaca, NY
    Posts
    145

    Connecting to MySQL over multiple pages

    I have multiple PHP scripts on my site and they all have separate connections to my MySQL databases. I want an easy way to share the same connection across these scripts without leaving any connections open after the user has left the site.

    I was thinking of using a session to carry the connection handle but the problem with this is if the user leaves the site, their database connection will remain open.

    I have a high volume of users and can't mess around with leaving MySQL connections open & unused and I also don't want to have them keep opening and closing connections constantly... it's a waste of valuable system resources.

    What is a good solution for this?

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Connecting to MySQL over multiple pages

    You can try using persistent connections.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2006
    Location
    Ithaca, NY
    Posts
    145

    Re: Connecting to MySQL over multiple pages

    ok that would work but how will these connections be closed? If I have 100 people using my site at once, all of them using a separate connection, am I going to run into resource issues?

    I guess my question is:

    What is going to use less system time, opening & closing a new connection in every script, or using a persistent connection for every script but having several open connections that aren't being used?

Posting Permissions

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



Click Here to Expand Forum to Full Width