Zend 2 Form旧密码验证
Zend 2 Form old password verification
我在数据库中的密码使用 MD5 加密,我如何使用 \Zend\Validator\Db\RecordExists 检查特定记录是否存在于 MD5 中?
'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',
),
),
),
根据 zend 文档,您可以这样尝试:
//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';
}
}
希望对您有所帮助
我在数据库中的密码使用 MD5 加密,我如何使用 \Zend\Validator\Db\RecordExists 检查特定记录是否存在于 MD5 中?
'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',
),
),
),
根据 zend 文档,您可以这样尝试:
//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';
}
}
希望对您有所帮助