[wp-hackers] Network activate, but only create one table

Alex Hempton-Smith hempsworth at gmail.com
Mon Jan 3 13:47:31 UTC 2011


Brilliant, thanks both!

-- Alex


On Mon, Jan 3, 2011 at 1:45 PM, Ulrich SOSSOU <sorich87 at gmail.com> wrote:

> >
> > Hi all,
> >
> > I'm working on the next version of BuddyPress Like, which will be
> creating
> > it's work table. I want it to work with MultiSite, but I only want there
> to
> > be one database table for the whole network rather than a separate one
> for
> > each site. This is so I can more easily bring up stats of the most
> 'liked'
> > content for the whole network.
> >
> > Currently, I'm using this code to create the database table, pretty
> normal:
> >
> >  $table_name = $wpdb->prefix . 'likes';
> > >
> > > if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {
> > >
> > > $sql[] = "CREATE TABLE $table_name (...
> >
> >
> > Which works fine, but when I network activate the plugin it's creating
> > wp_likes, wp_2_likes etc.
> >
> > How would I modify how I'm doing things to still respect any custom table
> > prefix that might be set, but only have one table for the whole network?
> >
> > -- Alex
>
>
>
> Use $wpdb->base_prefix.
>
> Ulrich SOSSOU
>
> --------------------------------------------
> Q: Why is this email five sentences or less?
> A: http://five.sentenc.es
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list