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 Link to comment https://forums.phpfreaks.com/topic/108790-mysql_close-absolutely-necessary/ 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. Link to comment https://forums.phpfreaks.com/topic/108790-mysql_close-absolutely-necessary/#findComment-558092 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. Link to comment https://forums.phpfreaks.com/topic/108790-mysql_close-absolutely-necessary/#findComment-558611 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. Link to comment https://forums.phpfreaks.com/topic/108790-mysql_close-absolutely-necessary/#findComment-558802 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.