Mysql
 sql >> Base de données >  >> RDS >> Mysql

les informations d'interrogation longue de mysql ne fonctionnent pas

Remplacez le code de votre fichier poll.php par :

<?php
include 'db.php';
$old_msg_id = $_GET['old_msg_id']; 
$result = mysql_query("SELECT id FROM chatpoll ORDER BY id DESC LIMIT 1");
while($row = mysql_fetch_array($result))
{
    $last_msg_id = $row['id']; 
}
while($last_msg_id <= $old_msg_id)
{
    usleep(1000);
    clearstatcache();
    $result = mysql_query("SELECT id FROM chatpoll ORDER BY id DESC LIMIT 1");
    while($row = mysql_fetch_array($result))
    {
        $last_msg_id = $row['id'];
    }
}
$response = array();
$response['msg'] = 'new';
$response['old_msg_id'] = $last_msg_id;
echo json_encode($response);
?>