add_clean_index

Adds an index to a specified table.

Description

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

Parameters (2)

0. $table (string)
Database table name.
1. $index (string)
Database table index column.

Usage

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

Defined (1)

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

/wp-admin/includes/upgrade.php  
  1. function add_clean_index($table, $index) { 
  2. global $wpdb; 
  3. drop_index($table, $index); 
  4. $wpdb->query("ALTER TABLE `$table` ADD INDEX ( `$index` )"); 
  5. return true;