woolyg Posted June 5, 2008 Share Posted June 5, 2008 Hi, Is mysql_close() absolutely necessary? The site I am coding uses quite a lot of mysql queries, all using the once connection, held in a <?php require "db.php"; ?> ..file. For each of the queries that I make from my pages, do you believe I should close off every query after it's finished? Your opinions please! -WoolyG Quote Link to comment Share on other sites More sharing options...
Hooker Posted June 5, 2008 Share Posted June 5, 2008 It's not absolutely necessary because if i remember correctly php handles that itself but its always best practice to close a connection when you're done. Quote Link to comment Share on other sites More sharing options...
jordanwb Posted June 5, 2008 Share Posted June 5, 2008 ^ I find your username strange. I put it in, better safe then sorry. Besides what have you got to lose? If you use a class in db.php just put: function __destruct () { mysql_close (); } And that's it. Quote Link to comment Share on other sites More sharing options...
TheFilmGod Posted June 6, 2008 Share Posted June 6, 2008 ^ I find your username strange. I put it in, better safe then sorry. Besides what have you got to lose? If you use a class in db.php just put: function __destruct () { mysql_close (); } And that's it. Your function is a waste of processing power. declaring __destruct() isn't much shorter or easier then mysql_close(); Hoóker was right. PHP will do any necessary closing of connections, fixing up things by itself to ensure functionality. Quote Link to comment 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.