I am working in a sensors project where many sensors outputs data which are stored in mysql table. I am using highcharts to visualize those data.
My problem is when I use the live mode, with an ajax call every second to my database, some data are not displayed since the ajax call fetch only the latest one and some points are dropped default of synchronization between the time when I push the data from sensors and the time to fetch them with ajax. I tried to synchronize this manually but I failed .
I am asking if there is a parameter that I can add to my sql queries to fetch only the data which has not been read yet, like this even if I push 3 data in one second with an ajax call made in on second I get only the not read data not the latest one.
I don’t know if this solution really exist and I am pretty new in php and mysql and I use them for research purpose only ,I need the simplest and the minimum solution !!
EDITI:: create new table last_point with last_point_id and last_point_info
I am using yii framework, I couldn’t make an update query using yii library
so I used this code
$modelSensor = SensorInfo2::model()->findBySql('SELECT * FROM information_sensors
where sensors_id= "'.$s['sensors_id'].'" ; ');
$sResult = array(intval($modelSensor->information_time ),intval($modelSensor-
>information_value ));
foreach ($modelSensor as $up) // for each value that I get from previous query
// I want to use it to
// update last_point table
{
$connection = yii::app()->db;
$sql = 'UPDATE last_point SET last_point_info =
"'.$up['information_time'].'"' ;
$command=$connection->createCommand($sql);
$command->execute();
}
$json = CJSON::encode($sResult);
echo $json ;
Yii::app()->end();
for my ajax query not problem and I still get my data, but the row last_point_info in the other table change to zero !
Any idea ? how the two tables should be connected ?
Many thanks in advance
I used 2 cdbcreteria one for geting the condition and another to get mydata using the first cdbcreteria as condition here
and finaly I update the time in the other table with foreach statement with this code