我收到错误
致命错误:在非对象上调用成员函数find()
当我添加以下代码时。虽然其余的工作除了sale_channel,当我尝试与其他人一样时,然后得到此错误。
public function beforeFilter() {
parent::beforeFilter();
$zones = $this->{$this->modelClass}->Zone->find("list", [
'conditions' => ['is_active' => 1],
'order' => ['name' => 'ASC']
]);
$states = $this->{$this->modelClass}->State->find("list", [
'conditions' => ['is_active' => 1],
'order' => ['name' => 'ASC']
]);
$cities = $this->{$this->modelClass}->City->find("list", [
'conditions' => ['is_active' => 1],
'order' => ['name' => 'ASC']
]);
$sale_channel = $this->{$this->modelClass}->SaleChannel->find("list", [
'conditions' => ['is_active' => 1],
'order' => ['name' => 'ASC']
]);
//$sale_channel = $this->SaleChannel->find("list", array('conditions' => array('is_active' => 1)));
$this->set(compact('zones', 'states', 'cities', 'sale_channel'));
}
型号代码
class SaleChannel extends AppModel {
/**
* Associations
*/
var $hasMany = array(
'Outlets' => array(
'className' => 'Outlet',
'foreignKey' => 'outlet_id',
'type' => 'INNER'
)
);
public $validate = array(
'name' => array(
'notEmpty' => array('rule' => array('notEmpty'), 'message' => 'This field is required.',
),
)
);
}