【问题标题】:CakePHP - Blank page on navigating to pageCakePHP - 导航到页面时的空白页面
【发布时间】:2011-08-02 15:53:19
【问题描述】:

我有以下控制器方法:

function recover_password() {
        $this->layout = 'frontend';
        $this->loadModel('PasswordReset');
        $this->Fonyker->recusive = -1;

        if($this->data) {
            $fields = array(
                'Fonyker.fonykid',
                'Fonyker.username',
                'Fonyker.name',
                'Fonyker.email'
            );

            $fonyker = $this->Fonyker->find('first', array(
                'conditions' => array(
                    'OR' => array(
                        'Fonyker.email' => $this->data['Fonyker']['field'],
                        'Fonyker.username' => $this->data['Fonyker']['field']
                    ) 
                ),
                'fields' => $fields
            ));

            if($fonyker) {
                $this->PasswordReset->create();

                $passwordReset = array();
                $passwordReset = array(
                    'PasswordReset' => array(
                        'code' => hash('sha256', $fonyker['Fonyker']['fonykid'].StringUtils::getRandomString(20)),
                        'fonykid' => $fonyker['Fonyker']['fonykid']
                    )
                );

                $this->PasswordReset->save($passwordReset);

                $data = array(
                    'username' => $fonyker['Fonyker']['username'],
                    'code' => $passwordReset['PasswordReset']['code'],
                    'name' => $fonyker['Fonyker']['name'],
                    'email' => $fonyker['Fonyker']['email']
                );

                $this->_sendPasswordResetEmail($data);

            } else {

            }
        } 
    }

这是视图:

<div class="prepend-top span-24">
    <div class="prepend-8 span-8 append-8">
        <?php

            echo $this->Form->create('Fonyker', array('action' => 'recover_password'));
            echo $this->Form->input('email', array(
                'div' => array(
                    'class' => 'span-8'
                ),
                'class' => 'input-text long',
                'id' => 'FonykerEmail',
                'label' => array(
                    'class' => 'inlined',
                    'text' => ''
                ),
                'placeholder' => 'Username or Email'
            ));

            echo $this->Form->submit('',array(
                'div' => array(
                    'class' => 'span-2 last'
                ),
            ));

            echo $this->Form->end();
        ?>
    </div>
</div>

当我导航到该页面时,我得到的只是一个空白页面,有时会出现此错误:Fatal error: Maximum execution time of 60 seconds exceeded in Unknown on line 0

更新:错误似乎正在加载我的模型,这是我声明的模型:

<?php
class PassswordReset extends AppModel {
    var $name = 'PasswordReset';
    var $displayField = 'id';
    var $validate = array(
        'code' => array(
            'alphanumeric' => array(
                'rule' => array('alphanumeric'),
                //'message' => 'Your custom message here',
                //'allowEmpty' => false,
                //'required' => false,
                //'last' => false, // Stop validation after this rule
                //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
        'fonykid' => array(
            'alphanumeric' => array(
                'rule' => array('alphanumeric'),
                //'message' => 'Your custom message here',
                //'allowEmpty' => false,
                //'required' => false,
                //'last' => false, // Stop validation after this rule
                //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        )
    );
}
?>

如果我删除 loadModel() 调用页面加载。

【问题讨论】:

    标签: php mysql cakephp view model


    【解决方案1】:

    您在数据库中有一个名为 password_resets 的表吗?此外,您可能希望在需要之前将 loadModel 移动到该行。

    【讨论】:

    • 是的,我愿意。会做的,谢谢。我已经解决了这个问题,由于某种原因 PasswordReset 似乎被系统保留了,当我将数据库表和模型名称更改为恢复/恢复时,它一切正常。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-09
    • 1970-01-01
    • 2020-10-07
    • 2022-08-02
    相关资源
    最近更新 更多