Analysis of implementation methods for batch deletion of thinkPHP and batch deletion of thinkphp
 
This example describes how to batch Delete thinkPHP. We will share this with you for your reference. The details are as follows:
 
Html:
 
<Li> <a class = "delete" href = "_ URL _/deleteSelected/navTabId/_ MODULE _" target = "selectedTodo" posttype = "string" calback = "navTabAjaxMenu" rel = 'kids' title = "are you sure you want to delete it? "Warn =" select nodes "> <span> batch Delete </span> </a> </li> <table class =" table "width =" 100% "layoutH = "138"> <thead> <tr> <th width = "10"> <input type = "checkbox" class = "checkboxCtrl" group = "ids"/> </th> <th width = "60"> NO. </th> </tr> </thead> <tbody> <volist id = "vo" name = "list"> <tr> <td> <input name = "ids" type = "checkbox" value = "{$ vo. id} "> </td> <td >{$ vo ['id'] }</td> </tr> </volist> </table> 
Php:
 
Public function deleteSelected () {// delete a specified record $ name = $ this-> getActionName (); $ model = D ($ name); if (! Empty ($ model) {$ pk = $ model-> getPk (); $ ids = $ _ REQUEST ['id']; if (! Empty ($ ids) {$ condition = array ($ pk => array ('in', explode (',', $ ids); if (false! ==$ Model-> where ($ condition)-> delete () {$ SQL = $ model-> _ SQL (); $ this-> success ("deleted successfully! ");} Else {$ this-> error ('deletion failed! ') ;}} Else {$ this-> error ('invalid operation ');}}} 
The principle is to pass an array when submitting a Web form, for example:
 
<input type="text" name="firstname"><input type="text" name="lastname"><input type="text" name="email"><input type="text" name="address"><input type="text" name="tree[tree1][fruit]"><input type="text" name="tree[tree1][height]"><input type="text" name="tree[tree2][fruit]"><input type="text" name="tree[tree2][height]"><input type="text" name="tree[tree3][fruit]"><input type="text" name="tree[tree3][height]">
 
The following information is passed:
 
$_POST[] = array(  'firstname'=>'value',  'lastname'=>'value',  'email'=>'value',  'address'=>'value',  'tree' => array(    'tree1'=>array(      'fruit'=>'value',      'height'=>'value'    ),    'tree2'=>array(      'fruit'=>'value',      'height'=>'value'    ),    'tree3'=>array(      'fruit'=>'value',      'height'=>'value'    )  ))