Skip to:
Content

BuddyPress.org

Opened 10 years ago

Closed 8 years ago

#5951 closed enhancement (wontfix)

Add all BP tables to $wpdb

Reported by: slaffik's profile slaFFik Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Core Keywords: needs-patch good-first-bug
Cc: slava.abakumov@…

Description

So it will be much easier to retrieve them, the same like $wpdb->posts or $wpdb->postmeta.

Currently only some of the tables are added: wp_bp_groups_groupmeta is added while wp_bp_groups is not.

Change History (10)

#1 @boonebgorges
10 years ago

  • Keywords reporter-feedback added

Can you say more about how they're easier to retrieve? $wpdb->bp_groups vs buddypress()->groups->table_name? It's not that I'm totally opposed, I just don't want to do it without good reason.

The meta tables are special cases - we put them there because WP's meta functions need them.

#2 @slaFFik
10 years ago

  • Cc slava.abakumov@… added
  • Keywords reporter-feedback removed

And that's the point. It's not consistent - some tables are available in $wpdb, others are not.
I have a habit to use $wpdb to retrieve DB table names (which is good, imo). And now in custom queries where post types are mapped to some groups (so wp_posts, wp_postmeta and wp_bp_groups etc in 1 query) I need to use different approach in getting table names.

I strongly believe, that:

$data = $wpdb->get_results($wpdb->prepare("SELECT ... FROM {$wpdb->posts}, {$wpdb->postmeta}, {$wpdb->bp_groups} WHERE ...", $data)); 

looks better, than:

$db_bp_groups = buddypress()->groups->table_name;
$data = $wpdb->get_results($wpdb->prepare("SELECT ... FROM {$wpdb->posts}, {$wpdb->postmeta}, {$db_bp_groups} WHERE ...", $data)); 

#3 @johnjamesjacoby
10 years ago

I tend to agree; they probably do belong in $wpdb.

We'll either need to add them to the BuddyPress class to maintain backwards compatibility, or add support for them in a magic getter method to pull from $wpdb when requested.

#4 @DJPaul
10 years ago

I don't really think there's any point. Consistency for consistency's sake here doesn't seem to offer any benefits. Adding them to let us use the WP meta API was the only reason we added what we already have.

If you want to patch them in, I don't mind, but I don't think we want to change all our buddypress()->groups->table_name etc queries in our SQL statements to use the wpdb syntax unless you have a really great reason.

#5 @boonebgorges
10 years ago

  • Keywords needs-patch added

I don't see a huge benefit myself, but there's also no harm in putting them there.

#6 @DJPaul
10 years ago

  • Milestone changed from Awaiting Review to Future Release

#7 @DJPaul
10 years ago

  • Keywords good-first-bug added

#8 @johnjamesjacoby
10 years ago

  • Component changed from Component - Any/All to Tools - Code Improvement

#9 @DJPaul
8 years ago

  • Component changed from Tools - Code Improvement to Core

#10 @DJPaul
8 years ago

  • Milestone Future Release deleted
  • Resolution set to wontfix
  • Status changed from new to closed

This has had no traction over two years nor any new demand, so let's not do this.

Note: See TracTickets for help on using tickets.