I am trying to find out the correct most efficient way to deal with mysql connections in PHP. My goal is to make sure I do not run out of connections. I have read that using persistent connections is a way to run out of connections if you have too many users. If opening and closing connections is not time intensive, will that be a better way to manage them?
Example:
$conn = mysql_connect(...);
mysql_select_db(..., $conn);
...
$info = mysql_query($query, $connection);
...
/* do a bunch of stuff to render the results to the screen */
...
mysql_close($conn);
If there is a lot of work to render to the screen, is it a better deal to save the query results off to another variable, free the resource memory and then close the connection before ever rendering to the screen?
Code examples would help, and documentation about how you know it is the best way is also preferred.
Thanks.
What is the best connection management design in PHP for mysql?
Here are some resources... I tend to the use the ezmysql/wordpress style with cache. I have yet to run into any performance issues or an overloaded mysql instance.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment