Skip to content

Instantly share code, notes, and snippets.

@kylejohnson
Created May 3, 2013 13:46
Show Gist options
  • Select an option

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

Select an option

Save kylejohnson/5509193 to your computer and use it in GitHub Desktop.
Error: Call to a member function find() on a non-object
File: /home/kjohnson/ZoneMinder/web/app/Model/Monitor.php
Line: 21
<?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'));
}
}
?>
<?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