"; 3. Delete multiple pieces of data through the "function del(){...}" method."/> "; 3. Delete multiple pieces of data through the "function del(){...}" method.">
Home >PHP Framework >ThinkPHP >How to delete multiple pieces of data in thinkphp
How to delete multiple pieces of data in thinkphp: 1. Open the template page file; 2. Write "14bc444c72c0a9ebf2b4345e797d7e29"; 3. Use the "function del(){...}" method to delete multiple pieces of data.
The operating environment of this tutorial: Windows 7 system, ThinkPHP version 5, Dell G3 computer.
How to delete multiple pieces of data in thinkphp?
ThinkPHP code example to implement batch deletion of data
ThinkPHP implements batch deletion of data The principle is very simple, just write 50611fd479c691a5a6a5b2cc37de59e8In this way, it is an array. The delete function del() of action is as follows:
/** **删除函数支持删除多条和一个 **/ 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('删除失败!'); } }
Recommended learning: "thinkPHP Video Tutorial"
The above is the detailed content of How to delete multiple pieces of data in thinkphp. For more information, please follow other related articles on the PHP Chinese website!