More wrapper functions for direct queries
|Reported by:||Viper007Bond||Owned by:|
I need to get the number of comments awaiting moderation. Apparently the only way to do this is a direct SQL query:
$comments = $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE comment_approved = '0'" );
The problem with this is forwards compatibility (what if the structure of the table is changed?) as well as more complex code.
I propose common queries such as approved comments, spam comments, comments in moderation, all comments, etc. be wrapped into functions that return the data. That way the function can be updated with no ill effects or changes to the code.
This could be applied to post queries as well.
Simply put, the less direct querying, the better IMO.