adrianTNT Posted April 28, 2009 Share Posted April 28, 2009 Hello. I have this situation in myny of my scripts: pconnect. if(something){ EXIT; } close_connection. Does that mean that connection would remain open? Quote Link to comment https://forums.phpfreaks.com/topic/155986-would-the-connection-remain-open-in-this-case/ Share on other sites More sharing options...
ignace Posted April 28, 2009 Share Posted April 28, 2009 No php automatically does what is called garbage collection when the end of the script has been reached Quote Link to comment https://forums.phpfreaks.com/topic/155986-would-the-connection-remain-open-in-this-case/#findComment-821127 Share on other sites More sharing options...
taith Posted April 28, 2009 Share Posted April 28, 2009 i would guess yes... if your exit;ing before the connection is closed... i could only assume that the pconnect would stay connected... just a guess... logical but still could be wrong... Quote Link to comment https://forums.phpfreaks.com/topic/155986-would-the-connection-remain-open-in-this-case/#findComment-821128 Share on other sites More sharing options...
adrianTNT Posted April 28, 2009 Author Share Posted April 28, 2009 Ok. What if I run two queries one after another with the same name and I only clear results ONCE after this? Will it be the same as I clear result after each query? recordset1 = "some query"; recordset1 = "some other query"; free_result recordset1; will it be the same (in terms of memory usage) with this? recordset1 = "some query"; free_result recordset1 recordset1 = "some other query"; free_result recordset1; Quote Link to comment https://forums.phpfreaks.com/topic/155986-would-the-connection-remain-open-in-this-case/#findComment-821415 Share on other sites More sharing options...
redarrow Posted April 28, 2009 Share Posted April 28, 2009 why are you using p connect please? was going to say, why use dream weaver then if false d to use p connect? in essence your worrying about nothing are you? i got some web sites, with 100 of query's one aft her another no problem. Quote Link to comment https://forums.phpfreaks.com/topic/155986-would-the-connection-remain-open-in-this-case/#findComment-821423 Share on other sites More sharing options...
adrianTNT Posted April 28, 2009 Author Share Posted April 28, 2009 pconnect is the default function for mysql in Dremaweaver so yes, that is what I use. Anyone has any answers ?! Quote Link to comment https://forums.phpfreaks.com/topic/155986-would-the-connection-remain-open-in-this-case/#findComment-821426 Share on other sites More sharing options...
ignace Posted April 29, 2009 Share Posted April 29, 2009 Sorry i didn't see you said pconnect Yes when you are using pconnect your connection remains open for future use. Which means that the connection will only be made once. So every new visitor will use the already existing open connection; You do not have to change your code or anything. pconnect will automatically checks if a connection already exists. If it exists, then it will use the already existing instead of creating a new connection. Persistent connections are used for performance but they may be a security problem. Quote Link to comment https://forums.phpfreaks.com/topic/155986-would-the-connection-remain-open-in-this-case/#findComment-821660 Share on other sites More sharing options...
adrianTNT Posted April 30, 2009 Author Share Posted April 30, 2009 Grr... I just realised that I was confusing the mysql_free_result that I have at the end of my scripts with mysql_close. It is mysql_free_result that is not always reached because it exits before it. So this will not cause too many connections problem, it will just use more ... RAM ? Or what memory? Quote Link to comment https://forums.phpfreaks.com/topic/155986-would-the-connection-remain-open-in-this-case/#findComment-822835 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.