自动验证的问题

浏览:481 发布日期:2013/06/25 分类:求助交流 关键字: 自动验证的问题
1:俺的模型
class UserModel extends Model{

protected $_validate = array(
array('username','require','验证码必须!'), //默认情况下用正则进行验证

);}

2、具体实现:
public function index(){

$user =D('User');

$user->username = $this->_post('username'); // 获取post变量

if (!$user->create()){
// 如果创建失败 表示验证没有通过 输出错误提示信息
echo "fail";
exit($user->getError());

}else{
// 验证通过 可以进行其他数据操作
echo "suc";
}

$this->display("index");
}
不填用户名提交,总是执行成功,没有自动验证,为什么啊?
论坛上有人说不用D方法,改成new Model()的方法,我就改成了 $user = new UserModel(),然后又报错,Class 'UserModel' not found F:\test\test\Lib\Action\IndexAction.class.php 第 14 行.




错误位置


FILE: F:\test\ThinkPHP\Lib\Core\Think.class.php  LINE: 275



TRACE


[13-06-25 00:31:06] F:\test\ThinkPHP\Lib\Core\Think.class.php (275) halt(Class 'UserModel' not found F:\test\test\Lib\Action\IndexAction.class.php 第 14 行.)
[13-06-25 00:31:06] F:\test\ThinkPHP\Lib\Core\Think.class.php (290) Think::appError(1, Class 'UserModel' not found, F:\test\test\Lib\Action\IndexAction.class.php, 14)
[13-06-25 00:31:06] () Think::fatalError()
,我把 3.1.2的ex扩展包放进框架里,但是还是不行,为什么了,大牛们帮帮忙吧
最佳答案
评论( 相关
后面还有条评论,点击查看>>