File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
src/Schema/Tables/Contracts Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -220,6 +220,28 @@ public function empty_table() {
220220
221221 $ this_table = static ::table_name ( true );
222222
223+ $ this ->db ::query ( "SET foreign_key_checks = 0 " );
224+ $ result = $ this ->db ::query ( "DELETE FROM {$ this_table }" );
225+ $ this ->db ::query ( "SET foreign_key_checks = 1 " );
226+
227+ return $ result ;
228+ }
229+
230+ /**
231+ * Truncates the custom table.
232+ *
233+ * @since TBD
234+ *
235+ * @return int|false The number of removed rows, or `false` to indicate a failure.
236+ */
237+ public function truncate () {
238+ if ( ! $ this ->exists () ) {
239+ // There is really nothing to empty here.
240+ return 0 ;
241+ }
242+
243+ $ this_table = static ::table_name ( true );
244+
223245 $ this ->db ::query ( "SET foreign_key_checks = 0 " );
224246 $ result = $ this ->db ::query ( "TRUNCATE {$ this_table }" );
225247 $ this ->db ::query ( "SET foreign_key_checks = 1 " );
You can’t perform that action at this time.
0 commit comments