Jump to content


Photo

free result or close


  • Please log in to reply
7 replies to this topic

#1 jcombs_31

jcombs_31
  • Staff Alumni
  • Advanced Member
  • 2,066 posts
  • LocationFL

Posted 20 April 2006 - 01:40 PM

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?

#2 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 20 April 2006 - 03:39 PM

I never use them. It's closed automatically for you at the end of script execution, so why bother?

Info: PHP Manual


#3 jcombs_31

jcombs_31
  • Staff Alumni
  • Advanced Member
  • 2,066 posts
  • LocationFL

Posted 20 April 2006 - 03:56 PM

[!--quoteo(post=366862:date=Apr 20 2006, 11:39 AM:name=ober)--][div class=\'quotetop\']QUOTE(ober @ Apr 20 2006, 11:39 AM) View Post[/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...

#4 redbullmarky

redbullmarky
  • Staff Alumni
  • Advanced Member
  • 2,863 posts
  • LocationBedfordshire, England

Posted 20 April 2006 - 05:52 PM

[!--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) View Post[/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.
"you have to keep pissing in the wind to learn how to keep your shoes dry..."

I say old chap, that is rather amusing!

#5 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 20 April 2006 - 06:45 PM

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!)

Info: PHP Manual


#6 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 20 April 2006 - 07:24 PM

I think you should be using mysql_close() when opening persistent connections with mysql_pconnect() as I don't think they close themself...

#7 redbullmarky

redbullmarky
  • Staff Alumni
  • Advanced Member
  • 2,863 posts
  • LocationBedfordshire, England

Posted 20 April 2006 - 09:51 PM

[!--quoteo(post=366969:date=Apr 20 2006, 08:24 PM:name=SemiApocalyptic)--][div class=\'quotetop\']QUOTE(SemiApocalyptic @ Apr 20 2006, 08:24 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
I think you should be using mysql_close() when opening persistent connections with mysql_pconnect() as I don't think 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.
"you have to keep pissing in the wind to learn how to keep your shoes dry..."

I say old chap, that is rather amusing!

#8 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 21 April 2006 - 08:45 AM

Oh! Must have got my wires crossed somewhere then - My appologies.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users