DatabaseUtil::drop_table_index()publicWC 1.0

Drops a table index, if both the table and the index exist.

Method of the class: DatabaseUtil{}

No Hooks.


true|false. True if the index has been dropped, false if either the table or the index don't exist.


$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() code WC 8.6.1

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;