Automattic\WooCommerce\Internal\Utilities
DatabaseUtil::drop_table_index
Drops a table index, if both the table and the index exist.
Method of the class: DatabaseUtil{}
No Hooks.
Returns
true|false. True if the index has been dropped, false if either the table or the index don't exist.
Usage
$DatabaseUtil = new DatabaseUtil(); $DatabaseUtil->drop_table_index( $table_name, $index_name ): bool;
- $table_name(string) (required)
- The name of the table that contains the index.
- $index_name(string) (required)
- The name of the index to be dropped.
DatabaseUtil::drop_table_index() DatabaseUtil::drop table index code WC 10.7.0
public function drop_table_index( string $table_name, string $index_name ): bool {
global $wpdb;
if ( empty( $this->get_index_columns( $table_name, $index_name ) ) ) {
return false;
}
// phpcs:ignore WordPress.DB.PreparedSQL
$wpdb->query( "ALTER TABLE $table_name DROP INDEX $index_name" );
return true;
}