in reply to SELECT COUNT and DBI: rows
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: SELECT COUNT and DBI: rows
by dws (Chancellor) on Sep 29, 2003 at 02:28 UTC | |
by Cody Pendant (Prior) on Sep 29, 2003 at 04:07 UTC | |
|
Re: Re: SELECT COUNT and DBI: rows
by CountZero (Bishop) on Oct 06, 2003 at 20:32 UTC |