Jump to content

Archived

This topic is now archived and is closed to further replies.

jcombs_31

free result or close

Recommended Posts

I've never really used the mysql_free_result() or mysql_close functions in my scripts. Are they really necessary. Do you guys use them?

Share this post


Link to post
Share on other sites
I never use them. It's closed automatically for you at the end of script execution, so why bother?

Share this post


Link to post
Share on other sites
[!--quoteo(post=366862:date=Apr 20 2006, 11:39 AM:name=ober)--][div class=\'quotetop\']QUOTE(ober @ Apr 20 2006, 11:39 AM) [snapback]366862[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I never use them. It's closed automatically for you at the end of script execution, so why bother?
[/quote]

that's what I thought, so why even have them? I don't understand the purpose or usage...

Share this post


Link to post
Share on other sites
[!--quoteo(post=366869:date=Apr 20 2006, 04:56 PM:name=jcombs_31)--][div class=\'quotetop\']QUOTE(jcombs_31 @ Apr 20 2006, 04:56 PM) [snapback]366869[/snapback][/div][div class=\'quotemain\'][!--quotec--]
that's what I thought, so why even have them? I don't understand the purpose or usage...
[/quote]

i might be guessing - i actually have mysql_free_result but only cos it's the way i learnt and just stuck with it out of habit - but wouldn't it make all the difference with say, for example, a large script that deals with large tables on a high traffic site? surely freeing up a result would take the load of the server a little? all the manual really states is that its to be used if youre worried about memory when dealing with large results.

as for mysql_close - not a clue.

Share this post


Link to post
Share on other sites
The only case I could imagine is if you were dealing with more than one DBMS and you wanted to close one and open another. *shrug* I've just never dealt with anything that big (although I might soon at work... they want me to graph some test results with 10Hz data... 2 tests with 12000 records each compared on one graph!)

Share this post


Link to post
Share on other sites
I think you should be using mysql_close() when opening persistent connections with mysql_pconnect() as I don't [i]think[/i] they close themself...

Share this post


Link to post
Share on other sites
[!--quoteo(post=366969:date=Apr 20 2006, 08:24 PM:name=SemiApocalyptic)--][div class=\'quotetop\']QUOTE(SemiApocalyptic @ Apr 20 2006, 08:24 PM) [snapback]366969[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I think you should be using mysql_close() when opening persistent connections with mysql_pconnect() as I don't [i]think[/i] they close themself...
[/quote]

according to the manual, it appears that mysql_close is used for non-persistent connections:

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
Note: mysql_close() will not close persistent links created by mysql_pconnect().
[/quote]and

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
Using mysql_close() isn't usually necessary, as non-persistent open links are automatically closed at the end of the script's execution.
[/quote]

does make you wonder though, how much coding gets done that isn't that necessary...how many other functions are like this and not required, etc...
still.

Share this post


Link to post
Share on other sites
Oh! Must have got my wires crossed somewhere then - My appologies.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.