samona Posted April 25, 2011 Share Posted April 25, 2011 I was wondering what the users at phpfreaks recommend as far as persistent database connections. Is it better to save the connection, or to open up a new connection for each page? Also, how would you have a persistent connection? Quote Link to comment https://forums.phpfreaks.com/topic/234657-persistent-mysql-database-connection/ Share on other sites More sharing options...
Maq Posted April 25, 2011 Share Posted April 25, 2011 Is it better to save the connection, or to open up a new connection for each page? Depends on what you're doing. Also, how would you have a persistent connection? mysql_pconnect Quote Link to comment https://forums.phpfreaks.com/topic/234657-persistent-mysql-database-connection/#findComment-1205871 Share on other sites More sharing options...
samona Posted April 25, 2011 Author Share Posted April 25, 2011 Thanks for the response. I want to create a login system using a mysql database instead of the default filesystem. I'm just wondering if its better to tear down the connection after each page and rebuild it on the next one. Also,I want to use object so I'm wondering if I should serialize those object or just store the values in the database and query them using the saved session value. Quote Link to comment https://forums.phpfreaks.com/topic/234657-persistent-mysql-database-connection/#findComment-1205875 Share on other sites More sharing options...
PFMaBiSmAd Posted April 25, 2011 Share Posted April 25, 2011 Persistent database connections cannot be 'saved'. You must still call the code on every page to get one of the existing persistent connections or to create a new persistent connection if an existing one is not available. Edit, Also, persistent connections only work on a very few web server/php configurations and in only the latest php versions. Quote Link to comment https://forums.phpfreaks.com/topic/234657-persistent-mysql-database-connection/#findComment-1205919 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.