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的一个指定的数据库表中删除一个索引。它是一个用于操作数据库表的辅助函数。

从一个表中删除指定的索引。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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;
}
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; }
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
查看更多 >