简体   繁体   English

Zend_Validate_Db_NoRecordExists-查询已损坏,不确定原因

[英]Zend_Validate_Db_NoRecordExists - query is broken, not sure why

I've written the following: 我写了以下内容:

  $email->addValidator('emailAddress', false)
        ->setRequired(true)
        ...
        ->addValidator(new Zend_Validate_Db_NoRecordExists(
            array(
                'table'   => 'site_users',
                'field'   => 'email',
            )
        ));

This isn't working and instead I'm getting the following error message: 这不起作用,相反,我收到以下错误消息:

Message: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; 消息:SQLSTATE [42000]:语法错误或访问冲突:1064 SQL语法有错误; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM site_users WHERE (`` = 'Test data4') LIMIT 1' at line 1 在第1行的'FROM site_users WHERE(``='Test data4')LIMIT 1'附近使用与您的MySQL服务器版本相对应的手册以获取正确的语法

Any ideas? 有任何想法吗?

Just had a look at the code and found this in the constructor for Zend_Validate_Db_Abstract (parent of Zend_Validate_Db_NoRecordExists ): 刚一看代码,发现这个在构造函数Zend_Validate_Db_Abstract (母公司Zend_Validate_Db_NoRecordExists ):

        $options       = func_get_args();
        $temp['table'] = array_shift($options);
        $temp['field'] = array_shift($options);
        if (!empty($options)) {
            $temp['exclude'] = array_shift($options);
        }

        if (!empty($options)) {
            $temp['adapter'] = array_shift($options);
        }

        $options = $temp;

So it expects the options to be in the correct order, and ignores the keys you specify! 因此,它期望选项的顺序正确,并忽略您指定的键! Bizarre. 奇怪 But it looks like your code should have still worked - what version of ZF are you running? 但是看来您的代码应该仍然有效-您正在运行哪个版本的ZF?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM