[PHP] Mysql_free_result() doubt

2006-09-26 Thread suresh kumar
Hi to all,
   I am little bit confused to use the mysql_free_result($result) 
function.because i searched google - they told dont use this function to php 
4.X and also it says clearly When you are done with a result set, you must 
free the memory it uses by calling mysql_free_result().
   
 I mean something like when  to use or not to use it? I already 
know that only SELECT  queries that  retrieve rows require to free resources, 
but maybe when all data is retrieved the resources are free automatically or we 
need to call mysql_free_result() to free the memory. and also this function 
will free only one row  at a time or all the rows of the  result set .
   

 A.suresh



-
 Find out what India is talking about on  - Yahoo! Answers India 
 Send FREE SMS to your friend's mobile from Yahoo! Messenger Version 8. Get it 
NOW

Re: [PHP] Mysql_free_result() doubt

2006-09-26 Thread Richard Lynch
On Tue, September 26, 2006 8:44 am, suresh kumar wrote:
I am little bit confused to use the
 mysql_free_result($result) function.because i searched
 google - they told dont use this function to php 4.X
 and also it says clearly When you are done with a
 result set, you must free the memory it uses by calling
 mysql_free_result().

  I mean something like when  to use or not to use it? I
 already know that only SELECT  queries that  retrieve
 rows require to free resources, but maybe when all data
 is retrieved the resources are free automatically or we
 need to call mysql_free_result() to free the memory. and
 also this function will free only one row  at a time or
 all the rows of the  result set .

PHP is going to free the data when your script ends, so most common
uses of MySQL don't even need mysql_free_result, as your page doesn't
do anything after it's done with MySQL anyway.

In some scripts, you are done with a large result set, and can gain
some performance by releasing all the resources tied to that result
set.

The argument to mysql_free_result is a result resource, and it frees
ALL the records, as you call it, and any other resources that result
set is using.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] mysql_free_result() question

2001-06-25 Thread Richard Lynch

  Do I mysql_free_result the $Query or the $Result? If it's $Result, would
  this be the same as just going unset($Result)?

 mysql_free_result() frees the ressources that the MySQL server allocated
for
 the results of your query. This is in the memory space of the MySQL
server,
 while if you unset($Result), it only frees the MySQL result id (an integer
 if I remember corretly) in the memory space of your script. So, no,
calling
 unset() is not the same to call mysql_free_result().

I could be wrong, and often am :-), but I believe that PHP4 knows about
MySQL resources, and if you don't have any variables capable of accessing
them any more (IE, you did unset($result)), then it's smart enough to do the
mysql_free_result for you...

This is, however, no excuse for you not writing less sloppy code in the
first place, now that you are educated enough to know what you are doing.
:-)  Use mysql_free_result() if the memory de-allocation is important to
you.

--
WARNING [EMAIL PROTECTED] address is an endangered species -- Use
[EMAIL PROTECTED]
Wanna help me out?  Like Music?  Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] mysql_free_result() question

2001-06-23 Thread Chris Cameron

I'm a bit unclear as to which result it is I use this function on.
So lets say I;
$Query = mysql_query(SELECT something FROM here);
$Result = mysql_fetch_assoc($Query);

Do I mysql_free_result the $Query or the $Result? If it's $Result, would
this be the same as just going unset($Result)?

Thanks,
Chris

--
If you don't find it in the index, look very carefully through the entire catalogue.
- Sears, Roebuck, and Co., Consumer's Guide, 1897


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] mysql_free_result() question

2001-06-23 Thread Kristian Duske

 Do I mysql_free_result the $Query or the $Result? If it's $Result, would
 this be the same as just going unset($Result)?

mysql_free_result() frees the ressources that the MySQL server allocated for
the results of your query. This is in the memory space of the MySQL server,
while if you unset($Result), it only frees the MySQL result id (an integer
if I remember corretly) in the memory space of your script. So, no, calling
unset() is not the same to call mysql_free_result().

Hope this helps.
Kristian


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] mysql_free_result() question

2001-06-23 Thread Jakob Kruse

You should call mysql_free_result($Query) !!

It all becomes a little clearer if you change the names of the variables as
such:

$result = mysql_query(select ...);
$row = mysql_fetch_assoc($result);

That is, mysql_query() returns a result, and mysql_fetch_*() returns a
row from such a result. Using mysql_free_result on a row is not advisable.

Also, in my terminology, the query would be the string passed to
mysql_query(), so you could do like this:

$query = select ...;
$result = mysql_query($query);
$row = ...

Regards,
Jakob Kruse

Chris Cameron [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 I'm a bit unclear as to which result it is I use this function on.
 So lets say I;
 $Query = mysql_query(SELECT something FROM here);
 $Result = mysql_fetch_assoc($Query);

 Do I mysql_free_result the $Query or the $Result? If it's $Result, would
 this be the same as just going unset($Result)?

 Thanks,
 Chris

 --
 If you don't find it in the index, look very carefully through the entire
catalogue.
 - Sears, Roebuck, and Co., Consumer's Guide, 1897




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] mysql_free_result

2001-04-20 Thread Randy Johnson

Does php release the memory used by the result set when it is done
executing?

if so why should I use mysql_free_result()


Thanks

Randy


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] mysql_free_result

2001-04-20 Thread Rasmus Lerdorf

 Does php release the memory used by the result set when it is done
 executing?

Correct

 if so why should I use mysql_free_result()

In case you are making multiple queries within the same script and want to
keep your runtime memory usage low.

-Rasmus


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]





RE: [PHP] mysql_free_result

2001-04-20 Thread Randy Johnson

Does the Mysql_free_result slow down the script at all?

Randy

-Original Message-
From: Rasmus Lerdorf [mailto:[EMAIL PROTECTED]]
Sent: Friday, April 20, 2001 8:49 PM
To: Randy Johnson
Cc: Php-General
Subject: Re: [PHP] mysql_free_result


 Does php release the memory used by the result set when it is done
 executing?

Correct

 if so why should I use mysql_free_result()

In case you are making multiple queries within the same script and want to
keep your runtime memory usage low.

-Rasmus



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] mysql_free_result

2001-04-20 Thread Rasmus Lerdorf

 Does the Mysql_free_result slow down the script at all?

Sure, calling the function will be slower than not calling it.  But not
significantly since the same operation will happen automatically.  The
difference being that you have the option of controlling exactly when you
want it to happen.

-Rasmus


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]