FOUND_ROWS() keeps returning 0

前端 未结 3 709
鱼传尺愫
鱼传尺愫 2021-01-06 17:41
$result = $db_con->query(\"SELECT SQL_CALC_FOUND_ROWS * FROM users LIMIT 0,10\");

$count_result = $db_con->query(\"SELECT FOUND_ROWS() as totalcount\");
$row          


        
3条回答
  •  轮回少年
    2021-01-06 18:11

    LIMIT is required to make found_rows() work correctly

    Add a LIMIT to the end of your query, ie.

    SELECT SQL_CALC_FOUND_ROWS * FROM users LIMIT 0,10;
    

    http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_found-rows

    FOUND_ROWS() -- For a SELECT with a LIMIT clause, the number of rows that would be returned were there no LIMIT clause

提交回复
热议问题