MySQL and PHP SQL_CAL_FOUND_ROWS and FOUND_ROWS ()

0

I'm trying to create a data display list that returns me the TOTAL of records so I can run the paging. To avoid doing 2 queries in a database with more than 5,000 records for the criteria I saw on the internet these 2 MySQL commands SQL_CAL_FOUND_ROWS and FOUND_ROWS (). However I could not get it to work.

My code:

$query_rs = "SELECT SQL_CAL_FOUND_ROWS cod, titulo, resumo, imagem
                 FROM livros 
                 WHERE sessao = 10 AND ativo = 1 AND sts > -1 AND cod NOT IN (15, 22, 28) 
                 ORDER BY ord_by DESC, cod DESC 
                 ". limit($limit);
$rs = mysqli_query($conn, $query_rs) or die(mysqli_error($conn));
$row_rs = mysqli_fetch_assoc($rs);
$totalRows_rs = mysqli_num_rows($rs);

Error: Unknown column 'SQL_CAL_FOUND_ROWS' in 'field list'

..... Also I did not understand where I insert in this script the procedure "SELECT FOUND_ROWS ()"

Thanks to everyone

    
asked by anonymous 09.08.2018 / 15:30

0 answers