Cakephp与可包含错误

Cakephp与可包含错误,cakephp,containable,Cakephp,Containable,我的appModel中有可包含的行为。 在我的资产模型中执行此操作时: $this->Asset->contain(); $this->find..... 我得到以下错误: 致命错误:对非对象调用成员函数contain() 但是,当我像这样使用contain时,它工作得很好: $this->find('all', array('conditions'=>array('Asset.name ='=>'goodAsset'), 'contain'=>fal

我的appModel中有可包含的行为。 在我的资产模型中执行此操作时:

$this->Asset->contain();
$this->find.....
我得到以下错误: 致命错误:对非对象调用成员函数contain()

但是,当我像这样使用contain时,它工作得很好:

$this->find('all', array('conditions'=>array('Asset.name ='=>'goodAsset'), 'contain'=>false) );

有什么想法吗?

您只在控制器中使用
$this->Model->method()。在模型中,从中间放置模型对象(因为
$this
已经指向它):


使用
debug($this->Asset->actsAs)
检查模型是否确实具有可包含的行为。无需调用$this->contain();设置'contain'=>false,它们都做相同的事情。
$this->contain();