首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Zend 2格式旧密码验证

Zend 2格式旧密码验证
EN

Stack Overflow用户
提问于 2015-10-29 08:20:53
回答 1查看 106关注 0票数 1

我的密码在DB中用MD5加密,我如何用MD5检查特定的记录是否存在,并使用\Zend\Validator\Db\RecordExist?

代码语言:javascript
复制
'validators' => array(

                        array(
                                'name' => '\Zend\Validator\Db\RecordExists',
                                'options' => array(
                                        'table' => 'users',
                                        'field' => 'password',
                                        'adapter' => $this->dbAdapter,

                                        'messages' => array(
                                                \Zend\Validator\Db\RecordExists::ERROR_NO_RECORD_FOUND=> 'Password not match',
                                        ),
                                ),
                ),
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-10-30 13:22:28

根据zend文档,您可以这样做:

代码语言:javascript
复制
//Validator declaration but the way you used it should work too.
$validator = new Zend_Validate_Db_RecordExists(
    array(
        'table' => 'users',
        'field' => 'password',
        'adapter' => $this->dbAdapter,
    )
);

if ($validator->isValid($recordToCheck)) {
    // Password exists
} else {
    // Password does not exists and we display the error message
    foreach ($validator->getMessages() as $message) {
        echo 'Password not match';
    }
} 

希望能帮上忙

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33409101

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档