我有这堂课:
<?php
class RegisterFilter extends InputFilter
{
public function __construct()
{
$this->add(array(
'name' => 'email1',
'required' => true,
'validators' => array(
array(
'name' => 'EmailAddress',
'options' => array(
'domain' => true,
),
),
array(
'name' => 'Identical',
'options' => array(
'token' => 'email2',
),
),
array(
'name' => 'Db\NoRecordExists',
'options' => array(
'table' => 'user',
'field' => 'email',
'messages' => array(
'recordFound' => "Email already exist ... ! <br>",
),
),
),
),
));
}
}
?>
我收到此错误:没有数据库适配器。任何想法为什么会这样?
答案 0 :(得分:0)
如果您阅读the documentation about Zend\Validator\Db\Record*
,那将是件好事。给定的错误消息意味着它所说的。您没有在Validator中提供DB-Adapter。
来自DOC:
$validator = new Zend\Validator\Db\RecordExists(
array(
'table' => 'users',
'field' => 'emailaddress',
'adapter' => $dbAdapter
)
);
如果您想了解如何将DB-Adapter放入表单,我已经写了a Blog Article关于该主题的内容。