Re: MySQL ResultSet - count rows?
- From: Ruud de Koter <nobody@xxxxxxxxxxxx>
- Date: Wed, 12 Dec 2007 23:12:41 +0100
Dyreatnews@xxxxxxx wrote:
Christoph <christoph.burschka@xxxxxxxxx> writes:
Hello,
I am writing the data of a ResultSet object to an array. To declare
the array length, I need to know the number of rows before copying
them - is there a way to read the row count instantly, without having
to iterate anything?
No. You could execute 'SELECT COUNT(*) ...' first but then you
essentially traverse all the rows twice.
One should realize that in doing so you are not determining the number of rows at the moment of retrieval, but the number of rows a few moments before the actual retrieval. Whether this is an important distinction depends with the volatility of the table and the use you will make if this number. On any system used by more than one user/process, these numbers *will* be different, sooner or later.
In short: this is not the way to go.
Regards,
Ruud de Koter.
.
(There could be non-standard MySQL extensions that lets you do this, I
don't know)
PHP has mysql_count_rows, but I'm not sure what that does internally -
it may just iterate over the data too.
- Follow-Ups:
- Re: MySQL ResultSet - count rows?
- From: Lew
- Re: MySQL ResultSet - count rows?
- References:
- MySQL ResultSet - count rows?
- From: Christoph
- Re: MySQL ResultSet - count rows?
- From: Dyreatnews
- MySQL ResultSet - count rows?
- Prev by Date: Yellowfin Business Intelligence Version 3.3 release
- Next by Date: Re: What does everyone else do for graphically displaying data?
- Previous by thread: Re: MySQL ResultSet - count rows?
- Next by thread: Re: MySQL ResultSet - count rows?
- Index(es):
Relevant Pages
|