如何批量删除ThinkPHP中的多条数据?

2026-04-02 18:001阅读0评论SEO教程
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计332个文字,预计阅读时间需要2分钟。

如何批量删除ThinkPHP中的多条数据?

在ThinkPHP中删除多条数据的方法:

1.打开模板页面文件;

2.在模板页面中添加复选框,格式为``;

如何批量删除ThinkPHP中的多条数据?

3.通过`function del() { ... }`方法实现删除多条数据。

thinkphp中删除多条数据的方法:1、打开模板页面文件;2、模板页面里面写上“<input name='id[]' type='checkbox' value='{$vo.id}' class="noborder">”;3、通过“function del(){...}”方法实现删除多条数据即可。

本教程操作环境:Windows7系统、ThinkPHP5版、Dell G3电脑。

thinkphp中怎么删除多条数据?

ThinkPHP实现批量删除数据的代码实例

ThinkPHP实现批量删除数据原理很简单,只需在模板页面里面写上<input name='id[]' type='checkbox' value='{$vo.id}' class="noborder">这样传过来就是一个数组,action的删除函数del()如下:

/** **删除函数支持删除多条和一个 **/ function del(){ //dump($_GET['id']); //$name = strtolower($_GET['_URL_'][0]); //获取当前模块名 $name = $this->getActionName(); $model = D($name);//获取当期模块的操作对象 $id = $_GET['id']; //判断id是数组还是一个数值 if(is_array($id)){ $where = 'id in('.implode(',',$id).')'; }else{ $where = 'id='.$id; } //dump($where); $list=$model->where($where)->delete(); if($list!==false) { $this->success("成功删除{$list}条!"); }else{ $this->error('删除失败!'); } }

推荐学习:《thinkPHP视频教程》

本文共计332个文字,预计阅读时间需要2分钟。

如何批量删除ThinkPHP中的多条数据?

在ThinkPHP中删除多条数据的方法:

1.打开模板页面文件;

2.在模板页面中添加复选框,格式为``;

如何批量删除ThinkPHP中的多条数据?

3.通过`function del() { ... }`方法实现删除多条数据。

thinkphp中删除多条数据的方法:1、打开模板页面文件;2、模板页面里面写上“<input name='id[]' type='checkbox' value='{$vo.id}' class="noborder">”;3、通过“function del(){...}”方法实现删除多条数据即可。

本教程操作环境:Windows7系统、ThinkPHP5版、Dell G3电脑。

thinkphp中怎么删除多条数据?

ThinkPHP实现批量删除数据的代码实例

ThinkPHP实现批量删除数据原理很简单,只需在模板页面里面写上<input name='id[]' type='checkbox' value='{$vo.id}' class="noborder">这样传过来就是一个数组,action的删除函数del()如下:

/** **删除函数支持删除多条和一个 **/ function del(){ //dump($_GET['id']); //$name = strtolower($_GET['_URL_'][0]); //获取当前模块名 $name = $this->getActionName(); $model = D($name);//获取当期模块的操作对象 $id = $_GET['id']; //判断id是数组还是一个数值 if(is_array($id)){ $where = 'id in('.implode(',',$id).')'; }else{ $where = 'id='.$id; } //dump($where); $list=$model->where($where)->delete(); if($list!==false) { $this->success("成功删除{$list}条!"); }else{ $this->error('删除失败!'); } }

推荐学习:《thinkPHP视频教程》