Jump to content

Database connections between scripts?


dukesdemise

Recommended Posts

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? 

Link to comment
https://forums.phpfreaks.com/topic/203647-database-connections-between-scripts/
Share on other sites

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.