Home>Article>Backend Development> About how thinkPHP implements batch deletion

About how thinkPHP implements batch deletion

不言
不言 Original
2018-06-08 14:11:43 3412browse

This article mainly introduces the implementation method of thinkPHP batch deletion, and analyzes the database and template operation related skills of thinkPHP to achieve batch deletion of data in the form of examples. Friends in need can refer to the following

The examples in this article describe Implementation method of batch deletion in thinkPHP. Share it with everyone for your reference, the details are as follows:

html:

  •   批量删除
  • 编号
    {$vo['id']}

    php:

    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('非法操作'); } } }

    The principle is that you can pass an array when submitting a web form. For example:

             

    Then what is passed is:

    $_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' ) ) )

    The above is the entire content of this article. I hope it will be helpful to everyone’s study. For more related content, please pay attention to the PHP Chinese website!

    Related recommendations:

    Based on Thinkphp and jquery, realize the function of ajax multi-selection, invert selection and delete data

    About thinkphp Framework to implement deletion and batch deletion analysis

    Use ThinkPHP framework to implement user information query and update and delete functions

    The above is the detailed content of About how thinkPHP implements batch deletion. For more information, please follow other related articles on the PHP Chinese website!

    Statement:
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn