How to get total number of returned records using MySQL


shimh

Recommended Posts

I use MySQL for logging. When I make an inquiry to the database via DAQFactory's db functions, I am wondering if it is a way to know the total number of returned records without going through all the records.

It is useful when the records are too many to fit one page. If I know the total number of records to be shown, I can calculate and display how many pages are there. Thanks.

Link to comment
Share on other sites

Actually, getting the number of records from a SQL query is kind of a pain in general. You have to do Select Count(*) where condition

That said, I'd use the db.querytoclass() function. Its not documented in the user's guide, but if you do a search on this forum you'll find all the details on using it in other posts. It returns the entire query in arrays, so you can just do numrows() on one of the arrays to get the number of records returned.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.