Created
May 3, 2013 02:05
-
-
Save kylejohnson/5506759 to your computer and use it in GitHub Desktop.
Attempting to apply $conditions to the $hasMany['Event'] array only
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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