BBP_Converter::sync_table( $drop = false )

Create Tables for fast syncing

Description

Source

File: bp-forums/admin/converter.php

540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
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.