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
The quickest solution is to subquery your actual query like this:
SELECT SQL_CALC_FOUND_ROWS * FROM (SELECT whatever FROM whatever WHERE whatever LIMIT whatever) ax;
select FOUND_ROWS();
Now you will get the correct results. I think the main reason being that SQL_CALC_FOUND_ROWS
mainly tracks rows found (i.e. without LIMITS
) not rows returned.