Today I ran into a problem with Yii2. I have a database with a list of numbers. These numbers are attached to clients. Every 5 senconds I update the page with jQuery to get the new records. My problem is that I only want do a notification when a new record arrives not every refresh (5 seconds)
Is there a solution to check if the database changed in Yii or should I do it in the client side?
Here is the controller method:
$behivott = Sorszam::find()->with('ablak')
->orderBy(['behivas_datum' => SORT_DESC])
->limit(1)
->all();
$sorszamok = Sorszam::find()->with('ablak')
->orderBy(['behivas_datum' => SORT_DESC])
->andWhere(['>', 'behivas_datum', 'nyomtatas_datum'])
->limit(4)
->offset(1)
->all();
$reklam = Reklam::find()->all();
return $this->render('generatePage', [
'sorszamok' => $sorszamok,
'reklam' => $reklam,
'behivott' => $behivott,
]);
Thank your for your answers!
Gábor
No, It's not poissible to do it server side with PHP.
The best you could do if you dont want to use AJAX is using websockets.
With websockets you can trigger an action in real time.