Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: DBI SQL Returns Less than Direct SQL

by Util (Priest)
on Oct 18, 2011 at 13:23 UTC ( #932150=note: print w/ replies, xml ) Need Help??


in reply to SOLVED: DBI SQL Returns Less than Direct SQL

Your use of $sth->rows() is buggy, and might be confusing the issue. From the DBI docs:

For SELECT statements, it is generally not possible to know how many rows will be returned except by fetching them all. Some drivers will return the number of rows the application has fetched so far, but others may return -1 until all rows have been fetched. So use of the rows method or $DBI::rows with SELECT statements is not recommended.


Comment on Re: DBI SQL Returns Less than Direct SQL
Download Code
Re^2: DBI SQL Returns Less than Direct SQL
by DaveNagy (Initiate) on Oct 18, 2011 at 15:33 UTC

    True! But, this count matches the rows returned in results arrays, whether as the result of an EXECUTE or other method.

    The documentation cautions that getting a count of rows might not work for certain drivers but doesn't explicitly say that for MySQL the results are not guaranteed. I had this code after the loop where I processed the results and the row count matches the number of rows returned in arrays (and for other search words, I do get more than 1 row but always less than shown in pure SQL via PHPAdmin and other query processes.)

    Thanks, Dave

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://932150]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2014-09-17 01:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (56 votes), past polls