| [reply] |
Asho!
I guess I was paying more attention to the:
"free up resources"
part of the documentation.
Will I run into problems using the same variable name $sth in multiple calls without a finish(), like this:
$sth=$dbh->prepare($sql);
$sth->execute;
while(($var)=$sth->fetchrow_array) { ... };
$sth=$dbh->prepare($sql2);
$sth->execute;
while(($var2)=$sthf->fetchrow_array) { ... };
I'm trying to make sure I understand how to do it right!
| [reply] [d/l] |
The code you show does *not* present a problem, in other words, it doesn't need finish(). You don't break out of the while loops, which means you do fetch all rows and therefore finish() is called automatically. The only time you need finish is if you fetch less than all rows e.g. you call one of the fetch methods outside of a loop, or if you call it in a loop but break out of the loop before all rows are fetched.
| [reply] |