我这个TP的动态验证怎么不起作用

WBOY
Release: 2016-06-20 12:48:19
Original
1110 people have browsed it

	function order_comment_submit()	{		$rules = array(		array('openid','require','openid不能为空!,3'),		array('order_id','require','order_id不能为空!,3'),		array('ims_order_id','require','ims_order_id不能为空!,3'),		array('type','require','type不能为空!,3'),		array('title','require','主题不能为空!,3')		);		$save_data['openid']         = 1;		$model = M('comment');		if(! $model->validate($rules)->create($save_data))		{			$this->error($model->getError());		}		exit('验证不起作用');	}
Copy after login


回复讨论(解决方案)

解决了,原来TP的验证有这个特性:虽然验证里设置了是不能为空的,但如果数据里没有那个字段项,或那个字段项为null,这个验证规则都会被绕过。

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template