Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/258.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
获取通知(8):CakePHP 1.2.5中未定义的属性错误_Php_Cakephp - Fatal编程技术网

获取通知(8):CakePHP 1.2.5中未定义的属性错误

获取通知(8):CakePHP 1.2.5中未定义的属性错误,php,cakephp,Php,Cakephp,我不知道为什么会出现上述错误。而且,在同一行中,我得到了可怕的结果 致命错误:对非对象调用成员函数query()错误 我有一个控制器home\u loan\u instance\u returnation\u controller.php,它有一个索引和视图方法 class HomeLoanInstallmentRepaymentController extends AppController { function index() { //some work done

我不知道为什么会出现上述错误。而且,在同一行中,我得到了可怕的结果
致命错误:对非对象调用成员函数query()
错误

我有一个控制器
home\u loan\u instance\u returnation\u controller.php
,它有一个
索引
视图
方法

class HomeLoanInstallmentRepaymentController extends AppController {

    function index() {
        //some work done here
    }

    function view() {
        //some work done here
    }
}
在这个控制器的查看页面
index.ctp
中,我正在调用另一个控制器
home\u loan\u installation\u returnation\u details\u controller.php
,它也有index()和view()方法。大概是这样的:

<td class="actions">
     <?php echo $html->link(__('View', true), array('action' => 'view', 'branch_id' => $branch_id, 'date' => $info[$i]['HomeLoanInstallmentRepayments']['REPAYMENT_DATE'])); ?>
      <a href="/sdb/HomeLoanInstallmentRepayment/edit/2014-11-25/branch_id:18">Edit</a>
      <a onclick="return confirm('Are you sure you want to delete # 2014-11-25?');" href="/sdb/HomeLoanInstallmentRepayment/delete/2014-11-25/branch_id:18">Delete</a>
      <!--The following link will navigate to a different controller-->
      <a href="/sdf-mis/HomeLoanInstallmentRepaymentDetails/index/branch_id:18">Installment Details</a>
</td>
在I$print\u r($info)之后,我会得到以下错误:

$info = $this-><your model name>->query("SOME SQL QUERY");

请注意,我没有上述两个控制器的任何模型,我绕过了使用模型的方法。

您正在使用控制器的实例调用该方法。您必须有一个模型才能对数据执行操作。
query()
是一个模型方法,因此请定义该模型。请尝试使用模型名称-

$info = $this->HomeLoanInstallmentRepaymentDetail->query("SOME SQL QUERY");
或者,如果您不想定义模型,则-


请注意,我没有上述两个控制器的任何模型,我绕过了使用模型。我建议你在回答之前仔细阅读我的整个问题。这很让人困惑。对于第一个控制器,我也没有任何模型,但是我在那里使用了query()方法,它工作得很好。如果我可以在没有模型的情况下使用query()方法作为第一个控制器,为什么第二个控制器不能使用它呢?我的问题可以通过将属性重命名为
HomeLoanInstallmentReturnmentDetail
而不是创建单个模型来解决。我甚至没有使用
ClassRegistry::init('AppModel')->query('query')函数,我也没有使用
var$uses=array()
。那我怎么还能正确使用控制器呢?这一切都是蛋糕做的。
homeloaninstallmentreturnmentdetail
应该是你的型号名称。没有必要。。Cake假设有一个具有该名称的模型和表格,尽管它没有定义…“在我过去的几篇帖子中,我注意到我收到的答案很少而且很晚。所以我希望有几个更快的回复和答案”-我认为你很幸运没有收到大量的反对票!
$info = $this-><your model name>->query("SOME SQL QUERY");
$info = $this->HomeLoanInstallmentRepaymentDetail->query("SOME SQL QUERY");
ClassRegistry::init('AppModel')->query('Your query');