Cakephp错误:发生内部错误

Cakephp错误:发生内部错误,cakephp,internal-server-error,Cakephp,Internal Server Error,我有一些cakephp代码,它会产生一个错误 以下是PHP控制器: $this->loadModel( 'Vote' ); //Newly added by amit start $vote=$this->Vote->getVote($id,$uid); $this->set('vote',$vote); $voteCount = count($vote); $this->set('voteCount',$voteCount); $voteShow = $this

我有一些cakephp代码,它会产生一个错误

以下是PHP控制器:

$this->loadModel( 'Vote' ); //Newly added by amit start
$vote=$this->Vote->getVote($id,$uid);
$this->set('vote',$vote);
$voteCount = count($vote);
$this->set('voteCount',$voteCount);

$voteShow = $this->Vote->find('all', array(
    'fields' => array('SUM(Vote.score)   AS score','count(id) as countId'),
     'conditions'=>array('Vote.type_id'=>$id),
));
$this->set('voteShow',$voteShow);
型号:

public function getVote($id,$uid) {
    if (empty($conditions))
        $conditions = array('Vote.type' => 'blog',
                            'Vote.type_id' => $id,
                            'Vote.user_id' => $uid);

    $users = $this->find('all', array('conditions' => $conditions,
        'order' => 'Vote.id desc'
    ));
    return $users;
}
该代码产生以下错误:

Error : An internal error has occurred

这个错误是什么意思?

我启用了调试模式:
Configure::write('debug',2)在我的例子中,调试模式是
Configure::write('debug',0)

我将其设置为
Configure::write('debug',1)并且这次没有显示错误

因此,我再次将调试模式更改为
Configure::write('debug',0)因为我不想在我的实时站点上显示调试错误

这次没有显示错误消息

所以只要在core.php中更改一次调试模式就可以了在我的例子中消除这个错误


如果将调试模式更改为1,然后在本地运行已更改的函数,CakePHP将刷新这些函数中包含的所有模型的缓存。现在,您可以在生产环境中更改回
Configure::write('debug',0)

不要设置
Configure::write('debug',2)
,或者当出现错误时,您可能会向用户写入敏感数据(如查询),debug 2之所以有效,是因为缓存中的项不再被考虑在内,所以它起作用了。只需删除缓存,并在生产环境中将调试保留为0,这一点非常重要

可以在这里找到缓存:
tmp/Cache/


同样,不要删除您将在那里找到的3个文件夹,只删除它们的内容。

不要在生产中这样做,否则当出现错误时,您可能会向用户写入敏感日期(如查询),debug 2工作的原因是缓存中的项不再被考虑,因此它可以工作。只需删除缓存,并在生产中将调试保留为0非常重要请参阅上面的我的答案,当您将其设置为1时,您就会明白它为什么工作!