Skip to content

Instantly share code, notes, and snippets.

@kylejohnson
Created May 3, 2013 02:05
Show Gist options
  • Select an option

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

Select an option

Save kylejohnson/5506759 to your computer and use it in GitHub Desktop.
Attempting to apply $conditions to the $hasMany['Event'] array only
<?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(
'Events.StartTime > DATE_SUB(NOW(), INTERVAL 1 HOUR)'
);
return $this->find('all', compact('conditions'));
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment