[wpmu-trac] [WordPress MU Trac] #1182: blog_id is set to 0 in wp_x_options?

WordPress MU Trac wpmu-trac at lists.automattic.com
Thu Dec 17 21:38:39 UTC 2009


#1182: blog_id is set to 0 in wp_x_options?
------------------------+---------------------------------------------------
 Reporter:  ancawonka   |       Owner:  somebody
     Type:  defect      |      Status:  new     
 Priority:  normal      |   Milestone:          
Component:  component1  |     Version:          
 Severity:  normal      |    Keywords:          
------------------------+---------------------------------------------------

Comment(by jamescollins):

 As far as I'm aware, that blog_id column is in normal WordPress as well,
 where it also is always set to zero.

 How many blogs do you need to get the blogname for?

 Because this blogname is stored in a different table for each blog (eg
 wp_1_options, wp_2_options, etc), I don't think it's possible to do what
 you're trying to do in 1 query because each blog id requires a join to a
 different table.

 How many blogs do you need to get the name for?

 Perhaps you could do something like (untested):

 {{{
 $blogids = array(1, 3, 5, 9); // array of blog ids to get the blogname of
 $blognames = array();
 foreach ($blogids as $id) {
     $blog = switch_to_blog($id);
     $blognames[$id] = get_option('blogname');
     restore_current_blog($blog);
 }
 // All the blognames are now stored in the $blognames array
 }}}

-- 
Ticket URL: <http://trac.mu.wordpress.org/ticket/1182#comment:1>
WordPress MU Trac <http://mu.wordpress.org/>
WordPress Multiuser


More information about the wpmu-trac mailing list