How to use MySQL Found_Rows() in PHP?

前端 未结 7 893
温柔的废话
温柔的废话 2020-12-03 16:55

I try to avoid doing Count() because of performance issue. (i.e. SELECT COUNT() FROM Users)

If I run the followings in phpMyAdmin, it is ok:



        
7条回答
  •  被撕碎了的回忆
    2020-12-03 17:22

    It's a common misconception, that SQL_CALC_FOUND_ROWS performs better than COUNT(). See this comparison from Percona guys: http://www.mysqlperformanceblog.com/2007/08/28/to-sql_calc_found_rows-or-not-to-sql_calc_found_rows/

    To answer you question: Only one query is allowed per one mysql_query call, as described in manual: mysql_query() sends a unique query (multiple queries are not supported)

    Multiple queries are supported when using ext/mysqli as your MySQL extension:

    http://www.php.net/manual/en/mysqli.multi-query.php

提交回复
热议问题