Zend Db_NoRecordExists - 检查多列
Zend Db_NoRecordExists 文档似乎仅限于检查一列。有没有办法在验证条目时检查多个密钥?例如,我允许不同城市使用相同的电子邮件地址。
这是我当前的验证器:
$email->setValidators(array(array('emailAddress'),
array('Db_NoRecordExists',false,
array(
'table'=>'usercities',
'field'=>'email',
))));
usercities 表有两列: 电子邮件 varchar(64) city_id tinyint
我希望能够检查这些列的组合。这可能吗?我想我必须创建一个自定义验证器。可以在不诉诸自定义类的情况下完成吗?
谢谢!
王子
Zend Db_NoRecordExists docs seem to be limited to checking only one column. Is there a way to check multiple keys when validating an entry? For example, I am allowing the same email address for different cities.
here's my current validator:
$email->setValidators(array(array('emailAddress'),
array('Db_NoRecordExists',false,
array(
'table'=>'usercities',
'field'=>'email',
))));
usercities table has two columns:
email varchar(64)
city_id tinyint
I want to be able to check for the combination of these columns. Is this possible? I assume I'll have to create a custom validator. Can it be done without resorting to a custom class?
thanks!
Oji
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
noup。你必须编写自定义验证器。尝试编写
App_Validate_Db_Select
代码,它将使用Zend_Db_Select
作为输入参数noup. u have to write custom validator. try to code
App_Validate_Db_Select
which will useZend_Db_Select
as input parameter