dukesdemise Posted June 2, 2010 Share Posted June 2, 2010 I am working on an application that makes a database connection after a valid login. This application will be made of several .php scripts, and these scripts will want to have access to the same database. What is the best way to share this database connection between several scripts? Quote Link to comment https://forums.phpfreaks.com/topic/203647-database-connections-between-scripts/ Share on other sites More sharing options...
kenrbnsn Posted June 2, 2010 Share Posted June 2, 2010 You can't do that (AFAIK) Ken Quote Link to comment https://forums.phpfreaks.com/topic/203647-database-connections-between-scripts/#findComment-1066696 Share on other sites More sharing options...
PFMaBiSmAd Posted June 2, 2010 Share Posted June 2, 2010 By opening a connection in each script that needs a connection. Web servers are stateless. All the resources used on any page request are destroyed when the server finishes serving each request. Even if you were on a web server/php combination that supported persistent database connections, each of your scripts must still execute the code necessary to get one of the existing persistent connections or create a new connection if no existing connection is available. Quote Link to comment https://forums.phpfreaks.com/topic/203647-database-connections-between-scripts/#findComment-1066762 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.