Created
May 3, 2013 13:46
-
-
Save kylejohnson/5509193 to your computer and use it in GitHub Desktop.
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
| Error: Call to a member function find() on a non-object | |
| File: /home/kjohnson/ZoneMinder/web/app/Model/Monitor.php | |
| Line: 21 |
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->Monitor->find('all', compact('conditions')); | |
| } | |
| } | |
| ?> |
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 MonitorsController extends AppController { | |
| public function index() { | |
| $this->set('monitors', $this->Monitor->find('all')); | |
| $EventsLastHour = $this->Monitor->getEventsLastHour(); | |
| } | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment