Home  >  Article  >  PHP Framework  >  How to delete multiple data in thinkphp

How to delete multiple data in thinkphp

藏色散人
藏色散人Original
2022-12-05 10:15:562215browse

Thinkphp method to delete multiple data: 1. Create a test data table in the mysql database; 2. In Thinkphp, create an index controller and inherit the Controller class; 3. Create a delMore( ) method, used to write code to delete data; 4. Use the $where variable to store multiple data IDs to be deleted; 5. Delete multiple pieces of data through the delete() method.

How to delete multiple data in thinkphp

The operating environment of this tutorial: Windows 7 system, ThinkPHP version 5, Dell G3 computer.

How to delete multiple data in thinkphp?

Thinkphp deletes multiple pieces of data from the data table

In Thinkphp, you can use the delete() method to delete multiple pieces of data from the database. The following editor will give an example to explain how to delete multiple pieces of data in a data table in Thinkphp.

Method

In the mysql database, create a test data table, and store three pieces of data in the data table.

How to delete multiple data in thinkphp

In Thinkphp, create an index controller and inherit the Controller class.

How to delete multiple data in thinkphp

In the index controller, create a delMore() method for writing code to delete data.

How to delete multiple data in thinkphp

In the delMore() method, use the $where variable to store multiple data IDs to be deleted.

How to delete multiple data in thinkphp

In the delMore() method, use the M() method to instantiate the object, delete multiple pieces of data through the delete() method, and then use the if statement to determine the result, and Output prompt.

How to delete multiple data in thinkphp

Open the delMore() method of the index controller in the browser to view the results.

How to delete multiple data in thinkphp

How to delete multiple data in thinkphp

Recommended study: "thinkPHP Video Tutorial"

The above is the detailed content of How to delete multiple data in thinkphp. 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