As a background background in MySQL with the SQL_CALC_FOUND_ROWS flag and the FOUND_ROWS () function, MySQL allows you to get the total number of rows that will be returned if SELECT did not use LIMIT, without having to issue a second heavy query:
$query = "SELECT SQL_CALC_FOUND_ROWS * from movies WHERE.... LIMIT 20"; $res1 = $db->query($query); $numrows = $db->query('SELECT FOUND_ROWS()')->fetchColumn();
This can be useful for pagination. Suppose you use a persistent connection:
try{ $db = new PDO('mysql:host=localhost;dbname=' . $dbname, $user, $pass, array( PDO::ATTR_PERSISTENT => true ) ); etc.
If two users click almost simultaneously, is there a way that requests could cross paths and could get the data requested by others?
source share