The MU forums have moved to WordPress.org

Adding a field to wp_blogs (7 posts)

  1. crsneilhedley
    Member
    Posted 14 years ago #

    In trying to search through my tables for another series of hacks I've come up with, I'm finding that I'm probably doing a TON of wasteful queries - in part because I'm using the Multi-DB plugin, but in part because the data for the searches I need is spread across a couple of tables.

    The whole thing could be streamlined in a BIG way if I could simply add a field to the wp_blogs table, namely "blogname", which would take it's info from the wp_options table as option_id 3 (at least in MY setup).

    Has this either been done (and I just couldn't find it), or is there a good reason why I *shouldn't* do it?

    Thanks.
    -- Neil

  2. tmoorewp
    Member
    Posted 14 years ago #

    You could use the switch_to_blog function and pull the blogname from the $wpdb variable. You could even put the switch_to_blog in a loop and give it a range of blog_ids.

  3. crsneilhedley
    Member
    Posted 14 years ago #

    @tmoorewp

    Yowza... didn't know it was that easy (it IS easy, yes?)

    Will do some research on exactly how to do what you're suggesting, as it's a function I'm not familiar with.

    Thanks!

  4. tdjcbe
    Member
    Posted 14 years ago #

    Either that or get_blog_option($blogid,'blogname').

    I think that's it.

    Reference: http://codex.wordpress.org/WPMU_Functions/get_blog_option

  5. crsneilhedley
    Member
    Posted 14 years ago #

    Hmmm... this thread...

    http://mu.wordpress.org/forums/topic/15951?replies=10

    ...seems to suggest that the overhead from using switch_to_blog makes the current brute-force method of pulling out info seem lighter in comparison. Will keep looking though - thanks!

  6. crsneilhedley
    Member
    Posted 14 years ago #

    @tdjcbe -
    You might have nailed it. THANK you!
    I'll let you know, for posterity, how I make out with it.

    ... will get_blog_option play nice with Multi-DB?

  7. tmoorewp
    Member
    Posted 14 years ago #

    get_blog_option should work wtih Multi-DB, since Multi-DB is supposed to be transparent to WordPress functions.

About this Topic

  • Started 14 years ago by crsneilhedley
  • Latest reply from tmoorewp