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
Well, it was a problem with mysql php extension bundled with php 5.2.6. Mysqli run fine, and another php version too. Sorry for noise and unclear question.
If you have the same problem, my advice is to re-install PHP or change version.