Edward Wilson <web2ed-/[EMAIL PROTECTED]> wrote:
This is really an important feature to have, I am surprised it's not
already there.  I too have had the same question but have just never
asked.

Well, if the golden standard is mysql_num_rows, consider the following bit in the documentation:

<quote>
The use of mysql_num_rows() depends on whether you use mysql_store_result() or mysql_use_result() to return the result set. If you use mysql_store_result(), mysql_num_rows() may be called immediately. If you use mysql_use_result(), mysql_num_rows() does not return the correct value until all the rows in the result set have been retrieved.
</quote>

mysql_store_result is essentially equivalent to sqlite3_get_table - it does not return until all rows are retrieved and stored in memory. Note that sqlite3_get_table does return the number of rows. Of course it is pretty useless for the purpose of providing progress indication.

mysql_use_result is equivalent to calling sqlite3_step in a loop - and just as in SQLite, MySQL cannot return the row count until all rows are fetched. Well, SQLite does not provide the row count in this case either, but you can easily maintain your own counter. Again, this does not help much with progress indicator.

The idea of issuing two selects is, well, a hack, and knowing how
many records one has in a result-set is a powerful feature.

The fundamental problem is that, for many queries, counting all rows is actually as complex a task as retrieving them in the first place. This is a property of SQL language and relational data model in general, it's not specific to SQLite or any other engine. There is no way around it.

Igor Tandetnik

Reply via email to