自动验证的静态验证过不了

浏览:542 发布日期:2014/03/19 分类:求助交流 关键字: 自动验证 BUG
这是表单
<form action='__APP__/Home/Index/test' method="post">
姓名:<input type="text" name='usersname'>
提交 <input type="submit"/>
</form>
这是控制器
<?php

namespace Home\Controller;

use Think\Controller;

class IndexController extends Controller {
public function index() {
$this->show();
}
public function test(){
$User=D('user');
if(!$User->create()){
dump( $User->getError());
}else {
echo 'successing';
}

}
}
这是模型
<?php

namespace Home\Model;

use Think\Model;

class UserModel extends Model {
protected $_map =array(
'username'=>'name'
);
protected $_auto = array (
array (
'name',
'md5',
3,
'function'
)
);
protected $_validate = array (

array (
'name',
'',
'帐号名称已经存在!',
1,
'unique',
1
) // 在新增的时候验证name字段是否唯一
)

;
}
永远提示我 账号已经存在 sqL 调试 最后运行的SQL 语句是


SHOW COLUMNS FROM `think_user` [ RunTime:0.003189s ]
SELECT * FROM `think_user` WHERE ( `name` = 0 ) LIMIT 1 [ RunTime:0.000265s ]

这说明压根模型就没有接受到我的值 拿0去验证 有BUG吧
最佳答案
评论( 相关
后面还有条评论,点击查看>>