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?
leondoornkamp
Member
Posted 1 year ago #
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.
The following will give you just the wp_ part.
global $wpdb;
print_r($wpdb->base_prefix);
leondoornkamp
Member
Posted 1 year ago #
Much appreciated! That does the trick for me!
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!
Sweet. I'll give it a try