Home > Article > PHP Framework > How to delete multiple data in thinkphp
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.
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.
In Thinkphp, create an index controller and inherit the Controller class.
In the index controller, create a delMore() method for writing code to delete data.
In the delMore() method, use the $where variable to store multiple data IDs to be deleted.
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.
Open the delMore() method of the index controller in the browser to view the results.
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!