summaryrefslogtreecommitdiffstats
path: root/wp-includes/wp-db.php
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2008-05-09 12:26:31 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2008-05-09 12:26:31 +0000
commit6c2e099541c67e7b75a62d5308d4e516215e282d (patch)
tree82491353405427ba0e56955215a4be133e190eaf /wp-includes/wp-db.php
parentcc9dc340688ff588971a7bf8cecebfbe89cf4095 (diff)
downloadwordpress-mu-6c2e099541c67e7b75a62d5308d4e516215e282d.tar.gz
wordpress-mu-6c2e099541c67e7b75a62d5308d4e516215e282d.tar.xz
wordpress-mu-6c2e099541c67e7b75a62d5308d4e516215e282d.zip
Added set_blog_id(), props rboren
Use set_blog_id() when switching blogs git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1279 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-includes/wp-db.php')
-rw-r--r--wp-includes/wp-db.php18
1 files changed, 18 insertions, 0 deletions
diff --git a/wp-includes/wp-db.php b/wp-includes/wp-db.php
index 341f9f2..dec8bc4 100644
--- a/wp-includes/wp-db.php
+++ b/wp-includes/wp-db.php
@@ -43,6 +43,8 @@ class wpdb {
'postmeta', 'terms', 'term_taxonomy', 'term_relationships');
var $charset;
var $collate;
+ var $blog_tables = array('posts', 'categories', 'post2cat', 'comments', 'links', 'link2cat', 'options', 'postmeta', 'terms', 'term_taxonomy', 'term_relationships');
+
/**
* Connects to the database server and selects a database
@@ -123,6 +125,22 @@ class wpdb {
return $old_prefix;
}
+ function set_blog_id($blog_id, $site_id = '') {
+ if ( !empty($site_id) )
+ $this->siteid = $site_id;
+
+ $old_blog_id = $this->blogid;
+ $this->blogid = $blog_id;
+
+ $this->prefix = $this->base_prefix . $this->blogid . '_';
+
+ foreach ( $this->blog_tables as $table )
+ $this->$table = $this->prefix . $table;
+
+ return $old_blog_id;
+ }
+
+
/**
* Selects a database using the current class's $this->dbh
* @param string $db name