Opened 10 years ago
Closed 8 years ago
#5951 closed enhancement (wontfix)
Add all BP tables to $wpdb
Reported by: | 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)
#2
@
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
@
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
@
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.
Can you say more about how they're easier to retrieve?
$wpdb->bp_groups
vsbuddypress()->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.