Mysql and PHP SQL_CAL_FOUND_ROWS and FOUND_ROWS()

Asked

Viewed 49 times

0

I am trying to create a data display list that returns the TOTAL of records for me to run after paging. To avoid making 2 queries in a database with more than 5 thousand records for the criteria I saw on the internet these 2 Mysql commands SQL_CAL_FOUND_ROWS and FOUND_ROWS(). However I could not put 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'

..... I also didn’t understand where to insert the "SELECT FOUND_ROWS()"

Thank you all

  • The correct is SQL_CALC_FOUND_ROWS.

  • And how to use it with PHP script and FOUND_ROWS()?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.