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_CALC_FOUND_ROWS
$sql = new mysqli
I had the same issue. The solution was stupid, I was using $wpdb->query instead of $wpdb->get_var. So you want to do
$wpdb->query
$wpdb->get_var
$wpdb->get_var('select FOUND_ROWS()');
if you're on WordPress