sql >> Database >  >> RDS >> Mysql

lange polling-info van mysql werkt niet

Wijzig de code in uw poll.php-bestand naar het volgende:

<?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);
?>



  1. overeenkomende tabelnaam met showtabellen

  2. Hoe u uw SQL Server-versie kunt controleren

  3. Hoe hebben Android-apps toegang tot MySQL?

  4. sqlalchemy + kolf, alle berichten per dag ontvangen