php-long-polling
php-long-polling copied to clipboard
Problems with database binding.
It was necessary to chat about this technology, everything seems to be usually updated on the example of the file, but how to update the query?
`set_time_limit(0);
while (true) {
$data_source_file = R::findLast('messages', 'dialog = ? ',array($_GET['getmess']));
$last_ajax_call = isset($_GET['timestamp']) ? (int)$_GET['timestamp'] : null;
clearstatcache();
$last_change_in_data_file = $data_source_file->date;
if ($last_ajax_call == null || $last_change_in_data_file > $last_ajax_call) {
$data = $data_source_file->message;
$result = array(
'data_from_file' => $data,
'timestamp' => $last_change_in_data_file
);
$json = json_encode($result);
echo $json;
break;
} else {
sleep(1);
continue;
}
}`
Well, roughly, the date of the last message looks like this $data_source_file->date;
Sorry I dont understand what you mean! Can you please give a error description ?
Error: works well with file change (test version), but can not work with sql-query