Home > Backend Development > PHP Tutorial > 请问下各位关于thinkphp开发的有关问题

请问下各位关于thinkphp开发的有关问题

WBOY
Release: 2016-06-13 12:03:46
Original
890 people have browsed it

请教下各位关于thinkphp开发的问题
小的刚接触MVC开发模式,用thinkphp开发的时候,用户提交过来的表单,对表单的验证是放在c层还是在m层呀?
------解决方案--------------------
thinkphp 内置的在model验证

如果你觉得不方便,可以接收参数在C进行手动验证。
------解决方案--------------------
封装在M层更好,入库前对必填字段和数据合法性都统一检查一遍
比如用户名密码必填且位数大于6,手机和邮箱格式等等
操作成功返回true,失败返回错误字符串,然后在C层根据情况$this->error()直接打印错误,还是ajax返回
M层的接口可以被C层多个页面调用

Related labels:
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