set_blog_id example


function wp_get_db_schema( $scope = 'all', $blog_id = null ) {
    global $wpdb;

    $charset_collate = $wpdb->get_charset_collate();

    if ( $blog_id && (int) $blog_id !== $wpdb->blogid ) {
        $old_blog_id = $wpdb->set_blog_id( $blog_id );
    }

    // Engage multisite if in the middle of turning it on from network.php.     $is_multisite = is_multisite() || ( defined( 'WP_INSTALLING_NETWORK' ) && WP_INSTALLING_NETWORK );

    /* * Indexes have a maximum size of 767 bytes. Historically, we haven't need to be concerned about that. * As of 4.2, however, we moved to utf8mb4, which uses 4 bytes per character. This means that an index which * used to have room for floor(767/3) = 255 characters, now only has room for floor(767/4) = 191 characters. */
    $max_index_length = 191;

    
if ( empty( $current_blog->site_id ) ) {
        // This dates to [MU134] and shouldn't be relevant anymore,         // but it could be possible for arguments passed to insert_blog() etc.         $current_blog->site_id = 1;
    }

    $site_id = $current_blog->site_id;
    wp_load_core_site_options( $site_id );
}

$wpdb->set_prefix( $table_prefix, false ); // $table_prefix can be set in sunrise.php. $wpdb->set_blog_id( $current_blog->blog_id, $current_blog->site_id );
$table_prefix       = $wpdb->get_blog_prefix();
$_wp_switched_stack = array();
$switched           = false;

// Need to init cache again after blog_id is set. wp_start_object_cache();

if ( ! $current_site instanceof WP_Network ) {
    $current_site = new WP_Network( $current_site );
}


        do_action( 'switch_blog', $new_blog_id$prev_blog_id, 'switch' );

        $GLOBALS['switched'] = true;

        return true;
    }

    $wpdb->set_blog_id( $new_blog_id );
    $GLOBALS['table_prefix'] = $wpdb->get_blog_prefix();
    $GLOBALS['blog_id']      = $new_blog_id;

    if ( function_exists( 'wp_cache_switch_to_blog' ) ) {
        wp_cache_switch_to_blog( $new_blog_id );
    } else {
        global $wp_object_cache;

        if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) ) {
            $global_groups = $wp_object_cache->global_groups;
        } else {
            
Home | Imprint | This part of the site doesn't use cookies.