What is a tried and true way to count the number of rows returned by the PHP function mysql_query?

I know about mysql_num_rows ( resource $result ), but I read somewhere that this is not 100% accurate. I saw other alternatives that actually get each line and start the counter, but that sounds pretty inefficient. I am interested to know what others are doing to get an accurate and effective score.

+3
source share
3 answers

Use mysql_num_rows()when you have completed the request SELECT, or SHOW, and mysql_affected_rows()in the case of queries INSERT, UPDATE, REPLACE or DELETE.
both are pretty accurate!

+2
source

mysql_num_rows() , mysql_unbuffered_query().

mysql_query(), mysql_num_rows() .

mysql_unbuffered_query(), mysql_num_rows() , .

+10

, , .

. - COUNT WHERE . . , 1000 , 10 .

, , . , , .

0

Source: https://habr.com/ru/post/1713718/


All Articles