I know there are various functions (in PHP or other programming languages) for getting the number of rows returned by a MySQL query result.
Unfortunately, when querying a very large table, sometimes PHP will run out of memory (for instance when running mysqli_query). Here are the requirements:
1) I know it s a select query, but that s all I know: it may be any query, involving joins, etc. I need a process that isn t query specific.
2) I want to be able to get the number of rows from the result, without fetching the result, since sometimes the result sets are quite large, and I run out of memory in PHP while it fetches the result.
3) I d rather not use buffered results, because I d have to fetch all the buffered results before I get an accurate count (costly).
4) Also unfortunately, I need it to be fairly agnostic to what API (e.g. pdo, mysqli, etc.) is used to fetch the results in PHP since I allow in the app for people to choose which API they ll use.
Thoughts?