OK I'm really confused indeed right now.
I've got working code which goes like this:
$sth = $dbh->prepare( " SELECT ## long complicated WHERE stuff " ) || die "Error: " . $dbh->errstr; $sth->execute() || die "Error: " . $dbh->errstr; if( $sth->rows > 0 ){ ## print out some results }
And according to this thread, I shouldn't do that, and I shouldn't rely on the results?
What should I do instead? Should I do the whole thing twice, like this?
$sth = $dbh->prepare( " SELECT COUNT(*) As Total ## long complicated WHERE stuff " ) || die "Error: " . $dbh->errstr; $sth->execute() || die "Error: " . $dbh->errstr; if( $Total > 0 ){ ## only if it passes this condition, do the REAL ## select and print out the results }
That seems bizarrely innefficient.
($_='kkvvttuubbooppuuiiffssqqffssmmiibbddllffss') =~y~b-v~a-z~s; print
In reply to Re: SELECT COUNT and DBI: rows
by Cody Pendant
in thread SELECT COUNT and DBI: rows
by perleager
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |