Zend Framework用户注册 - 添加到db

时间:2009-11-21 14:34:54

标签: php zend-framework

嘿,所以我正在编写一个php应用程序,我遇到了一个错误,我出于某些原因没有看到(我在编码时非常糟糕,睡眠不足可能与它有关。

无论如何,这是我棘手的问题:)

解析错误:语法错误,意外的$ end,期待T_FUNCTION

和代码:

模型

class Model_DbTable_Users extends Zend_Db_Table_Abstract
{
    protected $_name = 'users';

    public function addUser($username, $password, $email)
    {
        $data = array( 'username' => $username,
                       'password'    => $password,
                       'email'    => $email);
        $this->insert($data);
    }

和行动

public function stage1Action()
{
    $form = new Form_RegisterForm;
    $this->view->form = $form;

    $request = $this->getRequest();
    #if the form is submitted
    if($request->isPost()){
        #validated automatically by the form-errors echoed if invalid
        if($form->isValid($this->_request->getPost())) {
            $username = $form->getValue('username');
            $password = $form->getValue('password');
            $email = $form->getValue('email');

            $users = new Model_DbTable_Users;
            $users->addUser($username, $password, $email);

            $this->_helper->redirector('stage2');
        }
    }
}

按下提交按钮后我得到了这个动作。

任何帮助非常感谢。提前致谢

1 个答案:

答案 0 :(得分:2)

在实例化类时,看起来好像没有将()放在类名的末尾。改变这个:

$form = new Form_RegisterForm;

到这个

$form = new Form_RegisterForm();

Model_DbTable_Users执行相同的操作。

希望这有帮助!