|
@@ 7007-7046 (lines=40) @@
|
| 7004 |
|
* @return Array the date list |
| 7005 |
|
* |
| 7006 |
|
*/ |
| 7007 |
|
public function countAllDates() |
| 7008 |
|
{ |
| 7009 |
|
global $globalTimezone, $globalDBdriver; |
| 7010 |
|
if ($globalTimezone != '') { |
| 7011 |
|
date_default_timezone_set($globalTimezone); |
| 7012 |
|
$datetime = new DateTime(); |
| 7013 |
|
$offset = $datetime->format('P'); |
| 7014 |
|
} else $offset = '+00:00'; |
| 7015 |
|
|
| 7016 |
|
if ($globalDBdriver == 'mysql') { |
| 7017 |
|
$query = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
| 7018 |
|
FROM spotter_output |
| 7019 |
|
GROUP BY date_name |
| 7020 |
|
ORDER BY date_count DESC |
| 7021 |
|
LIMIT 10 OFFSET 0"; |
| 7022 |
|
} else { |
| 7023 |
|
$query = "SELECT to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') AS date_name, count(*) as date_count |
| 7024 |
|
FROM spotter_output |
| 7025 |
|
GROUP BY date_name |
| 7026 |
|
ORDER BY date_count DESC |
| 7027 |
|
LIMIT 10 OFFSET 0"; |
| 7028 |
|
} |
| 7029 |
|
|
| 7030 |
|
|
| 7031 |
|
$sth = $this->db->prepare($query); |
| 7032 |
|
$sth->execute(array(':offset' => $offset)); |
| 7033 |
|
|
| 7034 |
|
$date_array = array(); |
| 7035 |
|
$temp_array = array(); |
| 7036 |
|
|
| 7037 |
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
| 7038 |
|
{ |
| 7039 |
|
$temp_array['date_name'] = $row['date_name']; |
| 7040 |
|
$temp_array['date_count'] = $row['date_count']; |
| 7041 |
|
|
| 7042 |
|
$date_array[] = $temp_array; |
| 7043 |
|
} |
| 7044 |
|
|
| 7045 |
|
return $date_array; |
| 7046 |
|
} |
| 7047 |
|
|
| 7048 |
|
|
| 7049 |
|
|
|
@@ 8168-8205 (lines=38) @@
|
| 8165 |
|
* @return Array the hour list |
| 8166 |
|
* |
| 8167 |
|
*/ |
| 8168 |
|
public function countAllHoursFromToday() |
| 8169 |
|
{ |
| 8170 |
|
global $globalTimezone, $globalDBdriver; |
| 8171 |
|
if ($globalTimezone != '') { |
| 8172 |
|
date_default_timezone_set($globalTimezone); |
| 8173 |
|
$datetime = new DateTime(); |
| 8174 |
|
$offset = $datetime->format('P'); |
| 8175 |
|
} else $offset = '+00:00'; |
| 8176 |
|
|
| 8177 |
|
if ($globalDBdriver == 'mysql') { |
| 8178 |
|
$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
| 8179 |
|
FROM spotter_output |
| 8180 |
|
WHERE DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = CURDATE() |
| 8181 |
|
GROUP BY hour_name |
| 8182 |
|
ORDER BY hour_name ASC"; |
| 8183 |
|
} else { |
| 8184 |
|
$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
| 8185 |
|
FROM spotter_output |
| 8186 |
|
WHERE to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date) |
| 8187 |
|
GROUP BY hour_name |
| 8188 |
|
ORDER BY hour_name ASC"; |
| 8189 |
|
} |
| 8190 |
|
|
| 8191 |
|
$sth = $this->db->prepare($query); |
| 8192 |
|
$sth->execute(array(':offset' => $offset)); |
| 8193 |
|
|
| 8194 |
|
$hour_array = array(); |
| 8195 |
|
$temp_array = array(); |
| 8196 |
|
|
| 8197 |
|
while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
| 8198 |
|
{ |
| 8199 |
|
$temp_array['hour_name'] = $row['hour_name']; |
| 8200 |
|
$temp_array['hour_count'] = $row['hour_count']; |
| 8201 |
|
$hour_array[] = $temp_array; |
| 8202 |
|
} |
| 8203 |
|
|
| 8204 |
|
return $hour_array; |
| 8205 |
|
} |
| 8206 |
|
|
| 8207 |
|
/** |
| 8208 |
|
* Gets all the spotter information based on calculated upcoming flights |