Re: MySQL ResultSet - count rows?
- From: Arne Vajhøj <arne@xxxxxxxxxx>
- Date: Mon, 10 Dec 2007 20:21:49 -0500
Christoph wrote:
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?
PHP has mysql_count_rows, but I'm not sure what that does internally -
it may just iterate over the data too.
If you read the fine print in the PHP manual:
http://www.php.net/manual/en/function.mysql-num-rows.php
#Note: If you use mysql_unbuffered_query(), mysql_num_rows() will not
#return the correct value until all the rows in the result set have been
#retrieved.
You will see that it only return the the right number if you
either read all rows to memory with mysql_query or with
mysql_unbuffered_query have read all rows.
So in that sense PHP and JDBC are identical.
BTW, I agree completely with all those that have suggested
forgetting about the number and store the data in an
ArrayList.
Arne
.
- References:
- MySQL ResultSet - count rows?
- From: Christoph
- MySQL ResultSet - count rows?
- Prev by Date: Re: MySQL ResultSet - count rows?
- Next by Date: Re: MySQL ResultSet - count rows?
- Previous by thread: Re: MySQL ResultSet - count rows?
- Next by thread: Re: MySQL ResultSet - count rows?
- Index(es):
Relevant Pages
|
|