我上传了一个关于制作的CakePHP 应用程序。它正在我和我朋友的本地主机上运行。在生产中尝试访问不同的控制器时出现以下错误:
错误:调用非对象上的成员函数 find()
文件:/app/Controller/GroupsController.php
行:10
<?php
class GroupsController extends AppController {
var $name = 'Groups';
var $displayField = 'name';
var $helpers = array('Paginator', 'Html', 'Form');
function index() {
$groups = $this->Group->find('all');
$members = $this->Group->GroupMember->find('all', array('order' => array('GroupMember.date_checked DESC'))); //Line 10!
$owners = $this->Group->GroupContact->find('all', array('conditions' => array('GroupContact.owner' => 1)));
$this->set(compact('groups', 'members', 'owners'));
}
看起来它无法将 GroupMember 读取为对象。
模型 - groupMember.php
<?php
class GroupMember extends AppModel{
var $name = 'GroupMember';
var $belongsTo = array(
'Group' => array(
'className' => 'Group',
'foreignKey' => 'group_id'
)
);
}
?>
模型 - group.php
<?php
class Group extends AppModel{
var $name = 'Group';
var $hasMany = array(
'GroupMember' => array(
'className' => 'GroupMember',
'foreignKey' => 'id',
)
);
}
?>
您可以在http://www.thesupergroupproject.com/groups上查看错误
再次 - 该项目正在我的本地主机和我朋友的本地主机上运行。什么可能导致错误?