thinkphp 批量删除,其它批量操作类似

public function deleteSelected() {
    //删除指定记录
    $name = $this->getActionName();
    $model = D($name);
    if (!empty($model)) {
      $pk = $model->getPk();
      $ids = $_REQUEST['ids'];
      if (!empty($ids)) {
        $condition = array($pk => array('in', explode(',', $ids)));
        if (false !== $model->where($condition)->delete()) {
          $sql = $model->_sql();
          $this->success("删除成功!");
        } else {
          $this->error('删除失败!');
        }
      } else {
        $this->error('非法操作');
      }
    }
}

猜你喜欢

转载自blog.csdn.net/luoxiping1/article/details/80136489