add_clean_index

The timeline below displays how wordpress function add_clean_index has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 5.3

/**
 * Adds an index to a specified table.
 *
 * @since 1.0.1
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param string $table Database table name.
 * @param string $index Database table index column.
 * @return true True, when done with execution.
 */
function add_clean_index($table, $index)
{
    global $wpdb;
    drop_index($table, $index);
    $wpdb->query("ALTER TABLE `{$table}` ADD INDEX ( `{$index}` )");
    return true;
}

WordPress Version: 4.3

/**
 * Adds an index to a specified table.
 *
 * @since 1.0.1
 *
 * @global wpdb  $wpdb
 *
 * @param string $table Database table name.
 * @param string $index Database table index column.
 * @return true True, when done with execution.
 */
function add_clean_index($table, $index)
{
    global $wpdb;
    drop_index($table, $index);
    $wpdb->query("ALTER TABLE `{$table}` ADD INDEX ( `{$index}` )");
    return true;
}

WordPress Version: 4.2

/**
 * Adds an index to a specified table.
 *
 * @since 1.0.1
 *
 * @param string $table Database table name.
 * @param string $index Database table index column.
 * @return bool True, when done with execution.
 */
function add_clean_index($table, $index)
{
    global $wpdb;
    drop_index($table, $index);
    $wpdb->query("ALTER TABLE `{$table}` ADD INDEX ( `{$index}` )");
    return true;
}

WordPress Version: 3.7

/**
 * {@internal Missing Short Description}}
 *
 * {@internal Missing Long Description}}
 *
 * @since 1.0.1
 *
 * @param string $table Database table name.
 * @param string $index Database table index column.
 * @return bool True, when done with execution.
 */
function add_clean_index($table, $index)
{
    global $wpdb;
    drop_index($table, $index);
    $wpdb->query("ALTER TABLE `{$table}` ADD INDEX ( `{$index}` )");
    return true;
}