BBP_Converter::sync_table( $drop = false )

Create Tables for fast syncing

Description

Source

File: bp-forums/admin/converter.php

	public function sync_table( $drop = false ) {
		global $wpdb;

		$table_name = $wpdb->prefix . 'bbp_converter_translator';
		if ( ! empty( $drop ) && $wpdb->get_var( "SHOW TABLES LIKE '{$table_name}'" ) == $table_name )
			$wpdb->query( "DROP TABLE {$table_name}" );

		require_once( ABSPATH . '/wp-admin/includes/upgrade.php' );

		if ( !empty( $wpdb->charset ) ) {
			$charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
		}

		if ( !empty( $wpdb->collate ) ) {
			$charset_collate .= " COLLATE $wpdb->collate";
		}

		/** Translator ****************************************************/

		$sql = array();
		$max_index_length = 191;

		$sql[] = "CREATE TABLE {$table_name} (
					meta_id mediumint(8) unsigned not null auto_increment,
					value_type varchar(25) null,
					value_id bigint(20) unsigned not null default '0',
					meta_key varchar(255) null,
					meta_value varchar(255) null,
				PRIMARY KEY (meta_id),
					KEY value_id (value_id),
					KEY meta_join (meta_key({$max_index_length}), meta_value({$max_index_length}))
				) {$charset_collate};";

		dbDelta( $sql );
	}

Changelog

Changelog
Version Description
bbPress (r3813) Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.