Thinkphp中的curd应用实用要点
这个主要闲的没事给大家写一下curd的具体应用,当然这里边主要讲curd,我做的是用户的增删改查,没有用三大自动
首先
classIndexActionextendsAction{
publicfunctionindex(){
header(“Content-Type:text/html;charset=utf-8″);
$user=M(‘user');
$list=$user->select();
$this->assign(‘user',$list);
$this->display();
}
显示所有用户,首页做的注册
formaction=”__URL__/add”method=”post”>
用户名<inputtype=”text”name=”username”>
密码<inputtype=”text”name=”password”>
<inputtype=”submit”value=”提交”>
</form>
<volistname=”user”id=”vo”>
用户名:<inputname=”username”value=”<{$vo.username}>”>
密码:<inputname=”password”value=”<{$vo.password}>”>
注册IP:<inputname=”cip”value=”<{$vo.cip}>”>
注册时间:<inputname=”ctime”value=”<{$vo.ctime}>”>
<ahref=”__URL__/del/id/<{$vo.id}>”>删除</a>
<ahref=”__URL__/edit/id/<{$vo.id}>”>更新</a>
<br>
</volist>
然后就是我们的删除方法很简单思路是这样的我们获取ID删除这个ID的就可以了
if($user->where(‘$_GET[‘id']')->delete())
{ $this->success(‘删除成功'); }
热门推荐
10 小红书平安祝福语简短
11 生日祝福语大全女孩简短
12 收生日红包祝福语 简短
13 领证幽默祝福语简短
14 法考面试祝福语简短
15 老哥出门祝福语简短语
16 送灯祝福语简短独特
17 幼儿狗年祝福语大全简短
18 好听的元旦简短祝福语