zoneminder/web/app/Model/Monitor.php

44 lines
1.4 KiB
PHP
Raw Normal View History

2013-05-02 06:41:59 +08:00
<?php
class Monitor extends AppModel {
public $useTable = 'Monitors';
public $hasMany = array(
'Event' => array(
'className' => 'Event',
'foreignKey' => 'MonitorId'
),
'Zone' => array(
'className' => 'Zone',
'foreignKey' => 'MonitorId'
)
);
public function getEventsLastHour() {
$conditions = array('Event.StartTime > DATE_SUB(NOW(), INTERVAL 1 HOUR)');
$group = array('Event.MonitorId');
$fields = array('count(Event.Id) AS count');
return $this->Event->find('all', compact('conditions', 'group', 'fields'));
}
public function getEventsLastDay() {
$conditions = array('Event.StartTime > DATE_SUB(NOW(), INTERVAL 1 DAY)');
$group = array('Event.MonitorId');
$fields = array('count(Event.Id) AS count');
return $this->Event->find('all', compact('conditions', 'group', 'fields'));
}
public function getEventsLastWeek() {
$conditions = array('Event.StartTime > DATE_SUB(NOW(), INTERVAL 1 WEEK)');
$group = array('Event.MonitorId');
$fields = array('count(Event.Id) AS count');
return $this->Event->find('all', compact('conditions', 'group', 'fields'));
}
public function getEventsLastMonth() {
$conditions = array('Event.StartTime > DATE_SUB(NOW(), INTERVAL 1 MONTH)');
$group = array('Event.MonitorId');
$fields = array('count(Event.Id) AS count');
return $this->Event->find('all', compact('conditions', 'group', 'fields'));
}
2013-05-02 06:41:59 +08:00
}
?>