wpdb::set_blog_id( int $blog_id, int $network_id ): int

In this article

Sets blog ID.

Parameters

$blog_idintrequired
$network_idintoptional
Network ID. Default 0.

Return

int Previous blog ID.

Source

public function set_blog_id( $blog_id, $network_id = 0 ) {
	if ( ! empty( $network_id ) ) {
		$this->siteid = $network_id;
	}

	$old_blog_id  = $this->blogid;
	$this->blogid = $blog_id;

	$this->prefix = $this->get_blog_prefix();

	foreach ( $this->tables( 'blog' ) as $table => $prefixed_table ) {
		$this->$table = $prefixed_table;
	}

	foreach ( $this->tables( 'old' ) as $table => $prefixed_table ) {
		$this->$table = $prefixed_table;
	}

	return $old_blog_id;
}

Changelog

VersionDescription
3.0.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.