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?
Re: Connecting to MySQL over multiple pages
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?