1
1
Delete helper
2
2
-----------
3
+ #### drop multi tables
3
4
Suppose you want to drop multiple tables by their names in the database, you can do it with the following implementation.
4
5
``` php
5
6
6
7
QueryHelperFacade::deleteInstance()
7
- ->setTables(['posts', 'users' , 'comments']) // tables names.
8
+ ->setTables(['posts', 'users' , 'comments'])
9
+ // tables names.
10
+ // or you can select all tables that exists in the database from the below function
11
+ // ->setAllTablesFromDatabase()
8
12
->dropMultiTables()
9
13
->executeAll();
10
14
11
15
```
16
+ #### truncate multi tables
17
+
18
+ Suppose you want to truncate multiple tables by their names in the database, you can do it with the following implementation.
19
+ ``` php
20
+
21
+ QueryHelperFacade::deleteInstance()
22
+ // tables names.
23
+ ->setTables(['posts', 'users' , 'comments'])
24
+ // or you can select all tables that exists in the database from the below function
25
+ // ->setAllTablesFromDatabase()
26
+ ->truncateMultiTables()
27
+ ->executeWithoutPrepare();
28
+
29
+ ```
30
+
31
+ #### delete large data
12
32
If you have a table that contains a large number of data (maybe millions of records)
13
33
and you want to delete everything contained in this table,
14
34
if you execute the command with one query,
@@ -31,6 +51,8 @@ so this function divides the large query into more queries with an easy-to-use s
31
51
return $table->where('id', '<', 100)->pluck('id')->toArray();
32
52
}); // this will implement the delete process only on the result of this callback.
33
53
```
54
+
55
+ #### drop all tables
34
56
If you want to drop all tables from the database.
35
57
``` php
36
58
0 commit comments