• jskov

    (@jskov)


    I have upgraded a 2.9.1 wpmu installation to WP 3.0.1 MS.

    Now, I am having issues with the $wpdb->prefix reference in a few plugins. It seems to pull an individual blog’s prefix (ie. wp_#_ ) rather than the site prefix (ie. wp_ ).

    Is this correct? Is there something else that should be used instead? Is there something I am missing?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Leon

    (@leondoornkamp)

    I was just having a similar problem.

    You can get the variable out of wp-config.php >> $table_prefix
    which is bij default ‘wp_’
    So I thought I could be using that as site prefix, but apparantly wordpress adds ‘#_’ to this as well…

    So when you do the following on a plugin:

    global $table_prefix;
    var_dump( $table_prefix );

    it outputs ‘wp_#_’;

    But I also need it to output ‘wp_’;

    hope someone can explain.

    David Gard

    (@duck_boy)

    The following will give you just the wp_ part.

    global $wpdb;
    print_r($wpdb->base_prefix);
    Leon

    (@leondoornkamp)

    Much appreciated! That does the trick for me!

    David Gard

    (@duck_boy)

    No worries – If you are referencing a pre-existing table you can also use the $wpdb class to call the name of the table (including the correct base-prefix/prefix) For example, on my companies Client Balances site $wpdb->posts would return ‘wp_2_posts’ and $wpdb->users would return ‘wp_users’ – Very handy!

    Thread Starter jskov

    (@jskov)

    Sweet. I’ll give it a try

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Multisite Table Prefix "$wpdb->prefix" incorrect’ is closed to new replies.