Automattic\WooCommerce\Internal\Utilities

DatabaseUtil::drop_database_table()publicWC 1.0

Drops a database table.

Method of the class: DatabaseUtil{}

No Hooks.

Return

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->prefix before processing.
Default: false

DatabaseUtil::drop_database_table() code WC 8.7.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}`" );
}