Skip to content

Instantly share code, notes, and snippets.

@kylejohnson
Created November 11, 2013 14:01
Show Gist options
  • Select an option

  • Save kylejohnson/7413594 to your computer and use it in GitHub Desktop.

Select an option

Save kylejohnson/7413594 to your computer and use it in GitHub Desktop.
Monitors Has Many Events Events Has One Monitor
SELECT COUNT(*) AS `count` FROM `zm`.`Events` AS `Event` LEFT JOIN `zm`.`Monitors` AS `Monitor` ON (`Event`.`MonitorId` = `Monitor`.`Id`) WHERE `Event`.`MonitorId` = 1
$eventreport[$key] = $this->Event->find('count', array(
'conditions' => array(
'StartTime >=' => 'DATE_SUB(NOW(), INTERVAL 1 DAY)',
'MonitorId' => $monitor['Monitor']['Id']
),
'recursive' => -1
));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment