在null ;上调用成员函数find();CakePHP

在null ;上调用成员函数find();CakePHP,cakephp,cakephp-2.0,Cakephp,Cakephp 2.0,我试图在contacts表名中显示我的所有数据,但它给了我一个对null上的成员函数find()的错误调用。我不明白这是什么意思。请帮忙 <?php class ContactsController extends AppController { var $name = "Contacts"; public function index() { $this->set('

我试图在contacts表名中显示我的所有数据,但它给了我一个对null上的成员函数find()的错误调用。我不明白这是什么意思。请帮忙

<?php  
        class ContactsController extends AppController {
            var $name = "Contacts";

            public function index() {       
                $this->set('contacts', $this->Contacts->find('all'));
            }
        }
?>

在控制器中

<?php  
    class ContactsController extends AppController {
        public function index() {
            $this->set('contacts', $this->Contact->find('all'));  // here the change Contacts to Contact.
        }
    }
?>

你的模型

<?php  
    class Contact extends AppModel {
        var $name = "Contact";
    }
?>

在控制器中使用变量$use,如下所示

$use = array ('model_name');

只有

写下这个$这个->联系人->查找('all')我猜您使用的是cakephp 2,所以我添加了相应的标记