【问题标题】:CakePHP in plugin can't Load model插件中的 CakePHP 无法加载模型
【发布时间】:2017-09-29 19:59:58
【问题描述】:

我正在使用插件,我只想从我的表中加载数据作为 json,问题出在本地它正在工作,而在服务器中我在日志中发现了这个错误:

内部服务器错误 服务器遇到内部错误或配置错误,无法完成您的请求。 请通过 webmaster@localhost 联系服务器管理员,告知他们此错误发生的时间,以及您在此错误之前执行的操作。 服务器错误日志中可能会提供有关此错误的更多信息。

我的模特:

<?php
class Indisponibilite extends AppModel {

    var $name = 'Indisponibilite';

}

我的功能:

public function getIndisponible () {

    $indisponibles = ClassRegistry::init('Indisponibilite')->find('all');

    echo json_encode($indisponibles);

    $this->layout = 'ajax';  
    $this->autoRender = false;
    $this->render(false, "ajax");
    error_reporting(0);

}

【问题讨论】:

标签: apache cakephp cakephp-2.x


【解决方案1】:

首先:请查看有关 JSON Views 的文档,这些文档更接近 MVC 和 Cake-ish。对于 Cake 2.x,请检查 here。

另外,不要设置error_reporting。 CakePHP 应该为您处理所有这些。设置 Configure::write('debug', 0) 将为您关闭 error_reporting。

要查找您的错误,请检查日志,打开 debug 并查看上面的内容。

【讨论】:

  • 我的应用程序现在在服务器上,我找不到日志错误.. 请问在哪里可以找到它!
  • 这很大程度上取决于您的服务器设置,可能在文件夹log 中。 CakePHP error 和 debug 日志可以在 /logs 中找到。您描述的操作是唯一不起作用的操作吗?
  • 是的,它只是在我调用该模型时不起作用,我发现内部服务器错误!
猜你喜欢
  • 2016-09-30
  • 1970-01-01
  • 2015-06-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-08-15
相关资源
最近更新 更多