- 普通 - 未处理
| 这两天我一直在写三大自动的模型! 写的我都快要对think2.0失去兴趣了! 我一直调试,一直为错误! 不知道是我的代码写错了还是think2.0有错有BUG! 我抓狂了! 带写代码是要有耐心的,尤其是调试!所以耐着性子检测我的代码! 发现问题所在!终于发现了! 如下给出我的代码: class UserAction extends Action{ public function index(){ $this->display(); } public function register(){ $this->display(); } public function reg(){ $user=D('user'); $list=$user->create(); if($list){ $this->success('压入成功!'); }else{ $this->error("压入失败"); } } //验证码 public function verify(){ import([email=]'@.Org.Image'[/email]); Image::buildImageverify(); //Image::GBverify(); } } ?> class UserModel extends Model{ protected $_map=array( 'uname'=>'username', 'upass'=>'password', ); protected $_validate=array( array('uname','require','用户名必填'), array('uname','checklen','用户名长度过长或过短',0,'callback'), array('upass','require','密码必填'), array('repass','require','重复密码必填'), array('upass','repass','两次密码不一致',0,'confirm'), ); protected $_auto=array( array('password','md5',3,'function'), array('createip','returnip',1,'callback'), array('createtime','time',1,'function'), ); function returnip(){ return $_SERVER['REMOTE_ADDR']; } function checklen($data){ if(strlen($data)>15||strlen($data)<5){ return false; }else{ return true; } } } ?> 就是因为自动验证的信息提示不能显示出来,所以我一直认为是我的代码写错了! 左改右改还是不行,因为我调试都没有输入符合自动验证的数据,所以一直是错的,不能正常压入create(),提取表单信息! 后来就填写符合的,可以压入。 对照手册,又发现自己的没错! 就一直纠结了我两天了,一直写这个!一直错! 但是李文凯老师的视频都没有错(他写的代码),我跟着模仿的也没有错。自己亲自动手重写就错了! 那个汗,那个郁闷纠结啊! 不知道是不是BUG! 求解释! 谢谢! |
http://bbs.lampbrother.net/read-htm-tid-91897.html
