Alex Posted March 10, 2010 Share Posted March 10, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/194826-mysql-connections-in-php-application/ Share on other sites More sharing options...
roopurt18 Posted March 10, 2010 Share Posted March 10, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/194826-mysql-connections-in-php-application/#findComment-1024440 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.