我想在 cakephp 的组件文件中运行查询,但它显示致命错误,当我在控制器中执行此操作时,它工作得非常好,但我想在组件中执行此操作。
function product_check(){
$this->User = ClassRegistry::init('User');
$this->UserNode = ClassRegistry::init('UserNode');
$this->ProductsUserNode = ClassRegistry::init('ProductsUserNode');
$conditionss = array(
# http://book.cakephp.org/2.0/en/models/retrieving-your-data.html
'OR' => array(
array('ProductsUserNode.'. NODE_ID => $this->Auth->user(NODE_ID)),
array('ProductsUserNode.'. NODE_ID => $this->Auth->user(NODE_IDX)),
),
);
$productcheck = $this->User->UserNode
->ProductsUserNode
->find(
'first'
, array(
'conditions' => $conditionss
)
);
$active = $productcheck['ProductsUserNode']['is_active'];
if ($active == "0")
{
$this->Session->setFlash('You Are Deactived For This Product');
$this->redirect(array('controller'=>'events','action'=>'view_dashboard'));
}
}
但它显示了这个错误
Fatal Error
Error: Call to a member function user() on a non-object
我该如何解决这个问题?提前致谢