BBP_Converter::sync_table( $drop = false )
Create Tables for fast syncing
Description Description
Source Source
File: includes/admin/classes/class-bbp-converter.php
public static function sync_table( $drop = false ) {
// Setup DB
$bbp_db = bbp_db();
$table_name = $bbp_db->prefix . 'bbp_converter_translator';
$table_exists = $bbp_db->get_var( "SHOW TABLES LIKE '{$table_name}'" ) === $table_name;
// Maybe drop the sync table
if ( ( true === $drop ) && ( true === $table_exists ) ) {
$bbp_db->query( "DROP TABLE {$table_name}" );
}
// Maybe include the upgrade functions, for dbDelta()
if ( ! function_exists( 'dbDelta' ) ) {
require_once ABSPATH . '/wp-admin/includes/upgrade.php';
}
// Defaults
$sql = array();
$charset_collate = '';
// https://bbpress.trac.wordpress.org/ticket/3145
$max_index_length = 75;
// Maybe override the character set
if ( ! empty( $bbp_db->charset ) ) {
$charset_collate .= "DEFAULT CHARACTER SET {$bbp_db->charset}";
}
// Maybe override the collation
if ( ! empty( $bbp_db->collate ) ) {
$charset_collate .= " COLLATE {$bbp_db->collate}";
}
/** Translator ********************************************************/
$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({$max_index_length}) null,
meta_value varchar({$max_index_length}) 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 |
|---|---|
| 2.1.0 | Introduced. |