File tree 1 file changed +19
-18
lines changed
1 file changed +19
-18
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,23 @@ public function dropMultiTables()
33
33
return $ this ;
34
34
}
35
35
36
+ /**
37
+ * truncate multiple tables by their names in the database
38
+ *
39
+ * @return DeleteHelper
40
+ * @author karam mustafa
41
+ */
42
+ public function truncateMultiTables ()
43
+ {
44
+ $ this ->disableAndEnableForeignChecks (function () {
45
+ foreach ($ this ->tables as $ index => $ table ) {
46
+ $ this ->appendToQuery ("TRUNCATE $ table; " );
47
+ }
48
+ });
49
+
50
+ return $ this ;
51
+ }
52
+
36
53
/**
37
54
* this function is divide the process of deleting data into a number of queries,
38
55
* instead of making a large query that may take longer.
@@ -68,26 +85,10 @@ public function deleteLargeData(\Closure $callback = null)
68
85
*/
69
86
public function prepareDataBaseTablesToDrop ()
70
87
{
71
- $ this ->getAllTablesFromDatabase ();
72
-
73
- $ columnName = 'Tables_in_ ' .env ('DB_DATABASE ' );
74
-
75
- foreach ($ this ->getSavedItems () as $ table ) {
76
- $ this ->setTables ($ table ->$ columnName );
77
- }
78
-
79
- $ this ->dropMultiTables ();
88
+ $ this ->getAllTablesFromDatabase ()
89
+ ->dropMultiTables ();
80
90
81
91
return $ this ;
82
92
}
83
93
84
- /**
85
- * fetch all database tables.
86
- *
87
- * @author karam mustafa
88
- */
89
- private function getAllTablesFromDatabase ()
90
- {
91
- $ this ->setSavedItems (DB ::select ('SHOW TABLES ' ));
92
- }
93
94
}
You can’t perform that action at this time.
0 commit comments