thinPHP5模型删除数据的方法有两个一个是delete,一个是destroy方法,下面看实际案例代码。
<?php namespace app\index\controller; use think\Controller; use app\index\model\User;//调用模型 class Index extends Controller{ public function index(){ //destroy方法删除 $res=User::destroy(1); $res=User::destroy(['id'=>2]); $res=User::destroy(function($query){ $query->where("id","<",5); }); //delete方法删除 $userModel=User::get(1); $res=$userModel->delete(); //delete where方法删除 $res=User::where("id",2)->delete(); $res=User::where("id","<",5)->delete(); dump($res); } }