Re: no temp var for mysql_fetch_array results

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



David T-G wrote:

Justin, et al --

...and then Justin Patrin said...
% % David T-G wrote:
% % >...and then jeffrey_n_Dyke@xxxxxxxxx said...
% >% ...
% >% How about:
% >% $i = mysql_result(mysql_query($q,$dbro),0);
% >
% >Oooh! Cool! Just right.
...
% % Of course, this leaves the result handle open. It's best to store the % result handle and free it with mysql_free_result().


Makes sense.  I actually hadn't thought of that; do I need to do that
after a typical while(mysql_fetch_array()) or does the exhaustion caused
by the while loop then close and free for me?


Thanks & TIA & HAND


:-D

Nope, it's kept open so that you can use a seek to go back to the beginning i fyou want to (at least, I'm pretty sure that's what it's doing). You should always use mysql_free_result on your statement/result handle.


Of course, you don't *really* need to do this if your script is small as PHP will free everything when it's done, but it's good coding style and can keep you from (possibly) running out of memory in larger scripts.

--
paperCrane <Justin Patrin>

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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux