我的密码在DB中用MD5加密,我如何用MD5检查特定的记录是否存在,并使用\Zend\Validator\Db\RecordExist?
'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',
),
),
),发布于 2015-10-30 13:22:28
根据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';
}
} 希望能帮上忙
https://stackoverflow.com/questions/33409101
复制相似问题