Jump to content

mysql connections in php application


Alex

Recommended Posts

I have a PHP application that is running from the CLI. This application will sometimes require a connection to a mysql database. I was wondering if I should create and close a new mysql connection every time I need to preform a query on the database, or if I should just keep one open throughout the entire duration of the program. If the latter I assume that because it's a single execution of the script (even though the duration will be very long periods of time) using a normal connection vs a persistent connection would have no effect.

Link to comment
https://forums.phpfreaks.com/topic/194826-mysql-connections-in-php-application/
Share on other sites

The only problem I can see with a long-lived connection is if your program isn't using it, i.e. it goes idle, the server may kill it.  You'd want your program to detect if the server has killed the connection and re-open it if it has.

 

Other than that I'm not sure it really matters.

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.