Automattic\WooCommerce\Internal\Utilities
DatabaseUtil::drop_database_table
Drops a database table.
Method of the class: DatabaseUtil{}
No Hooks.
Returns
true|false. True on success, false on error.
Usage
$DatabaseUtil = new DatabaseUtil(); $DatabaseUtil->drop_database_table( $table_name, $add_prefix );
- $table_name(string) (required)
- The name of the table to drop.
- $add_prefix(true|false)
- True if the table name passed needs to be prefixed with
$wpdb->prefixbefore processing.
Default:false
DatabaseUtil::drop_database_table() DatabaseUtil::drop database table code WC 10.5.0
public function drop_database_table( string $table_name, bool $add_prefix = false ) {
global $wpdb;
if ( $add_prefix ) {
$table_name = $wpdb->prefix . $table_name;
}
//phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
return $wpdb->query( "DROP TABLE IF EXISTS `{$table_name}`" );
}