I use SQL_CALC_FOUND_ROWS
in Mysql SELECT statement, to get the number of lines my SELECT would return without a LIMIT clause.
$sql = new mysqli
Are you using a MySQL query method that allows for multiple queries.
From MySQL documentation.
To obtain this row count, include a
SQL_CALC_FOUND_ROWS
option in the SELECT statement, and then invokeFOUND_ROWS()
afterward
Example:
mysql> SELECT SQL_CALC_FOUND_ROWS * FROM tbl_name
-> WHERE id > 100 LIMIT 10;
mysql> SELECT FOUND_ROWS();
Also just for fun, there's a great discussion about the race condition of FOUND_ROWS()
's usage here.