List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:November 1 2001 1:05am
Subject:Re: HOW do I return the results of a count to a variable
View as plain text  
At 4:10 PM -0800 10/31/01, Bill Adams wrote:
>Paul DuBois wrote:
>
>>  [snip]
>>
>>  >Of all the methods suggested I like the look of the one above and will
>>  >try that one first.
>>  >
>>  >$count = $sth->fetchrow_array();
>>  >
>>  >$rows = $sth->rows()
>>
>>  Note that use of rows() to get the row count for a SELECT is deprecated
>>  in the DBI docs, which say that if you want to know the number of rows
>>  in a result set, fetch and count them.  (The reason is that rows()
>>  just doesn't work at all for some database engines.  On the other hand,
>>  it appears to work just fine for MySQL...)
>
>Yes, MySQL will return the number of rows you /will/ get en total.  Informix,
>Oracle, etc.. return the number of rows you have retrieved so far.
>
>This is a database implementation issue and not a DBI/DBD issue. 
>(PHP follows the
>same results.)  Therefore if you want your code to work across dbs, you should
>not rely on the value of ->rows().
>
>b.

I agree with all of that except that it's not a DBI/DBD issue.  Because
this is a db implementation issue, that makes it a DBI issue, because
people seem to want to rely on rows(), even though it's deprecated for
SELECT.
Thread
(errno: 40)Eric Dean29 Oct
  • Re: (errno: 40)mickalo29 Oct
  • HOW do I return the results of a count to a variableMark Worsdall31 Oct
    • Re: HOW do I return the results of a count to a variablemickalo31 Oct
    • Re: HOW do I return the results of a count to a variablemickalo31 Oct
    • Re: HOW do I return the results of a count to a variablePaul DuBois31 Oct
      • Re: HOW do I return the results of a count to a variableMark Worsdall31 Oct
        • Re: HOW do I return the results of a count to a variablePaul DuBois1 Nov
  • Having trouble using LIMITMark Worsdall31 Oct
    • Re: Having trouble using LIMITSteve Meyers31 Oct
      • Re: Having trouble using LIMITMark Worsdall31 Oct
    • Re: Having trouble using LIMITPaul DuBois31 Oct
  • Re: HOW do I return the results of a count to a variableAnne Shroeder31 Oct
  • Re: HOW do I return the results of a count to a variableBill Adams1 Nov
    • Re: HOW do I return the results of a count to a variablePaul DuBois1 Nov
  • Re: HOW do I return the results of a count to a variableHarald Fuchs1 Nov
    • Re: HOW do I return the results of a count to a variablePaul DuBois2 Nov