drop_index

函式
drop_index ( $table, $index )
引數
  • (string) $table Database table name.
    Required:
  • (string) $index Index name to drop.
    Required:
返回值
  • (true) True, when finished.
定義位置
相關方法
noindexget_dropinsadd_clean_index_get_dropinsdo_action
引入
1.0.1
棄用
-

drop_index: 這個函式從WordPress的一個指定的資料庫表中刪除一個索引。它是一個用於運算元據庫表的輔助函式。

從一個表中刪除指定的索引。

function drop_index( $table, $index ) {
	global $wpdb;

	$wpdb->hide_errors();

	$wpdb->query( "ALTER TABLE `$table` DROP INDEX `$index`" );

	// Now we need to take out all the extra ones we may have created.
	for ( $i = 0; $i < 25; $i++ ) {
		$wpdb->query( "ALTER TABLE `$table` DROP INDEX `{$index}_$i`" );
	}

	$wpdb->show_errors();

	return true;
}

常見問題

FAQs
檢視更多 >