本文介绍了CakePHP:调用非对象上的成员函数find()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 查看我的管理员索引时出现以下错误I get the following errors when viewing my Admin IndexNotice (8): Undefined property: ClientsController::$Clients [APP/controllers/clients_controller.php, line 27]Call to a member function find() on a non-object in /Users/cameron/Sites/crm/app/controllers/clients_controller.php on line 27这里是代码:class ClientsController extends AppController{ var $name = 'Clients'; function beforeFilter() { parent::beforeFilter(); $this->Auth->allow(array('*')); } function index() { $this->set('clients', $this->Clients->find('all')); } function view ( $id, $slug ) { $article = $this->Clients->read(null, Tiny::reverseTiny($id)); $this->set(compact('client')); } function admin_index() { $this->set('clients', $this->Clients->find('all')); }任何想法都是什么问题? (我也创建了一个模型)Any ideas what the issue is here? (I have created a Model also)推荐答案一些潜在的问题:通常var $name = 'Client'; // Not Clients您有一个客户端,并且控制器用于客户端。You have a Client, and the controller is for "Clients".尝试:$this->set('clients', $this->Client->find('all')); with the above suggestion on var $name.如果这不会导致你走错正确的路径,请参阅更完整的潜在解决方案列表。See a more complete list of potential solutions here if that doesn't lead you down the right path. CakePHP调用非对象的成员函数 这篇关于CakePHP:调用非对象上的成员函数find()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-23 13:13