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

Otto otto at ottodestruct.com
Mon Jan 3 13:45:01 UTC 2011


Use $wpdb->base_prefix instead.

-Otto



On Mon, Jan 3, 2011 at 7:40 AM, Alex Hempton-Smith <hempsworth 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
> _______________________________________________
> 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