CakePHP - 导航到页面的空白页面

时间:2011-08-02 15:53:19

标签: php mysql cakephp view model

我有以下控制器方法:

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()调用页面加载。

1 个答案:

答案 0 :(得分:1)

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