无法调试对非对象的成员函数find()的cakephp错误调用
这是我的模型无法调试对非对象的成员函数find()的cakephp错误调用,cakephp,Cakephp,这是我的模型 <?php class Survey extends AppModel { // model associations public $belongsTo = array( 'Organisation' => array( 'className' => 'Organisation', 'foreignKey' => 'organisation_id' ), 'Account' =>
<?php
class Survey extends AppModel {
// model associations
public $belongsTo = array(
'Organisation' => array(
'className' => 'Organisation',
'foreignKey' => 'organisation_id'
),
'Account' => array(
'className' => 'Account',
'foreignKey' => 'account_id'
),
'User' => array(
'className' => 'User',
'foreignKey' => 'user_id'
),
'Country' => array(
'className' => 'Country',
'foreignKey' => 'country_id'
),
'Currency' => array(
'className' => 'Currency',
'foreignKey' => 'currency_id'
)
);
}
?>
我有一个包含货币的数据库表,我正在尝试将其填充到select中的Survey视图中。我已检查模型和控制器的命名是否正确。我的关联类似于我正在使用的country select,它工作正常,但我在货币查找中遇到了这个错误,我已经尝试调试了几个小时
Fatal Error
Error: Call to a member function find() on a non-object
File: C:\xampp\htdocs\cakephp2-5-3\app\Controller\SurveysController.php
Line: 29
错误消息告诉您在哪里查找:SurveysController.php的第29行
很可能您正在调用未包含的模型上的find。如果是Survey,则需要将其添加到控制器中的$uses属性,以便加载它。但如果我在SurveysController中的某个函数中,则不需要将Survey添加到$uses属性权限?@RichardRoss否。因为您已覆盖$uses数组,您需要再次显式声明调查public$uses=array'Report'、'Mycase'、'Workflow'、'Survey';。CakePHP不知道如何将其重新合并,因为它认为您试图覆盖默认行为。谢谢您,Martin,您解决了我的问题。我爱你@理查德罗斯真棒
$currencies = $this->Survey->Currency->find('list');
Fatal Error
Error: Call to a member function find() on a non-object
File: C:\xampp\htdocs\cakephp2-5-3\app\Controller\SurveysController.php
Line: 29