drop_index

Drops a specified index from a table.

Description

drop_index( (string) $table, (string) $index ); 

Parameters (2)

0. $table (string)
Database table name.
1. $index (string)
Index name to drop.

Usage

  1. if ( !function_exists( 'drop_index' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/upgrade.php'; 
  3.  
  4. // Database table name. 
  5. $table = ''; 
  6.  
  7. // Index name to drop. 
  8. $index = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = drop_index($table, $index); 
  12.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/includes/upgrade.php  
  1. function drop_index($table, $index) { 
  2. global $wpdb; 
  3. $wpdb->hide_errors(); 
  4. $wpdb->query("ALTER TABLE `$table` DROP INDEX `$index`"); 
  5. // Now we need to take out all the extra ones we may have created 
  6. for ($i = 0; $i < 25; $i++) { 
  7. $wpdb->query("ALTER TABLE `$table` DROP INDEX `{$index}_$i`"); 
  8. $wpdb->show_errors(); 
  9. return true;