-
+
WeatherMon (аÑÑ Ð¸Ð²)
+
prepare(
'select
- date_format(timestamp,\'%Y\') as year
+ date_format(day,\'%Y\') as year
from
- sensor_values
+ calendar
group by year
order by year');
$q -> execute();
@@ -37,7 +57,7 @@ if (! $year) {
fetch(PDO::FETCH_ASSOC)) {
?>
- ÐаннÑе за год
+ ÐаннÑе за год
prepare(
'select
- date_format(timestamp,\'%m\') as month,
- date_format(timestamp,\'%d\') as day
+ date_format(day,\'%m\') as month,
+ date_format(day,\'%d\') as day
from
- sensor_values
+ calendar
where
- timestamp>=str_to_date(\''.$year.'-01-01\',\'%Y-%m-%d\') and
- timestamp=str_to_date(\''.$year.'-01-01\',\'%Y-%m-%d\') and
+ day'.$month_name.'';
+ echo '
';
}
@@ -96,18 +116,18 @@ if (! $year) {
$q = $db -> prepare (
'select
s.id sensor,p.id param,s.s_description sensor_name,p.st_description param_name,
- count(distinct date_format(v.timestamp,\'%d\')) cnt,
- round(min(v.value),1) min_value,
- round(max(v.value),1) max_value,
+ count(distinct day) cnt,
+ round(min(v.min),1) min_value,
+ round(max(v.max),1) max_value,
u.name_short unit
from
- sensor_values v,sensors s,st_parameters p,units u
+ sensors_ranges v,sensors s,st_parameters p,units u
where
- v.sensor_id=s.id and
- v.parameter_id=p.id and
+ v.sensor=s.id and
+ v.parameter=p.id and
p.st_unit=u.id and
- v.timestamp>=str_to_date(\''.$year.'-01-01\',\'%Y-%m-%d\') and
- v.timestamp=str_to_date(\''.$year.'-01-01\',\'%Y-%m-%d\') and
+ v.day prepare(
'select
- date_format(timestamp,\'%d\') as day
+ date_format(day,\'%d\') as day
from
- sensor_values
+ sensors_ranges
where
- timestamp>=str_to_date(\''.$year.'-'.$month.'-01\',\'%Y-%m-%d\') and
- timestamp=str_to_date(\''.$year.'-'.$month.'-01\',\'%Y-%m-%d\') and
+ day prepare (
'select
s.id sensor,p.id param,s.s_description sensor_name,p.st_description param_name,
- count(distinct date_format(v.timestamp,\'%d\')) cnt,
- round(min(v.value),1) min_value,
- round(max(v.value),1) max_value,
+ count(distinct day) cnt,
+ round(min(v.min),1) min_value,
+ round(max(v.max),1) max_value,
u.name_short unit
from
- sensor_values v,sensors s,st_parameters p,units u
+ sensors_ranges v,sensors s,st_parameters p,units u
where
- v.sensor_id=s.id and
- v.parameter_id=p.id and
+ v.sensor=s.id and
+ v.parameter=p.id and
p.st_unit=u.id and
- v.timestamp>=str_to_date(\''.$year.'-'.$month.'-01\',\'%Y-%m-%d\') and
- v.timestamp=str_to_date(\''.$year.'-'.$month.'-01\',\'%Y-%m-%d\') and
+ v.day prepare(
'select
- distinct v.sensor_id,s.s_description,p.id as param_id,p.st_description
+ distinct v.sensor as sensor_id,s.s_description,p.id as param_id,p.st_description
from
- sensor_values v,st_parameters p,sensors s
+ sensors_ranges v,st_parameters p,sensors s
where
- v.timestamp>=str_to_date(\''.$year.'-'.$month.'-'.$day.'\',\'%Y-%m-%d\') and
- v.timestamp execute();